Skip to content

Commit 52ec6ea

Browse files
authored
Enable compilation failures on warnings for driver module main sources (#1275)
This is primarily an extra protection from unintended warnings.
1 parent d2178ab commit 52ec6ea

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+223
-24
lines changed

driver/clirr-ignored-differences.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,4 +334,10 @@
334334
<method>java.lang.String neo4jErrorCode()</method>
335335
</difference>
336336

337+
<difference>
338+
<className>org/neo4j/driver/QueryRunner</className>
339+
<differenceType>7012</differenceType>
340+
<method>void close()</method>
341+
</difference>
342+
337343
</differences>

driver/src/main/java/org/neo4j/driver/Config.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import static org.neo4j.driver.internal.logging.DevNullLogging.DEV_NULL_LOGGING;
2323

2424
import java.io.File;
25+
import java.io.Serial;
2526
import java.io.Serializable;
2627
import java.net.InetAddress;
2728
import java.util.ArrayList;
@@ -70,6 +71,7 @@
7071
*/
7172
@Immutable
7273
public class Config implements Serializable {
74+
@Serial
7375
private static final long serialVersionUID = -4496545746399601108L;
7476

7577
private static final Config EMPTY = builder().build();

driver/src/main/java/org/neo4j/driver/QueryRunner.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,7 @@
2323
*
2424
* @since 1.0
2525
*/
26-
public interface QueryRunner extends SimpleQueryRunner, AutoCloseable {}
26+
public interface QueryRunner extends SimpleQueryRunner, AutoCloseable {
27+
@Override
28+
void close() throws RuntimeException;
29+
}

driver/src/main/java/org/neo4j/driver/SessionConfig.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import static java.util.Objects.requireNonNull;
2222
import static org.neo4j.driver.internal.handlers.pulln.FetchSizeUtil.assertValidFetchSize;
2323

24+
import java.io.Serial;
2425
import java.io.Serializable;
2526
import java.util.Arrays;
2627
import java.util.Objects;
@@ -34,6 +35,7 @@
3435
* The session configurations used to configure a session.
3536
*/
3637
public class SessionConfig implements Serializable {
38+
@Serial
3739
private static final long serialVersionUID = 5773462156979050657L;
3840

3941
private static final SessionConfig EMPTY = builder().build();

driver/src/main/java/org/neo4j/driver/TransactionConfig.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import static java.util.Objects.requireNonNull;
2424
import static org.neo4j.driver.internal.util.Preconditions.checkArgument;
2525

26+
import java.io.Serial;
2627
import java.io.Serializable;
2728
import java.time.Duration;
2829
import java.util.HashMap;
@@ -63,6 +64,7 @@
6364
* @see Session
6465
*/
6566
public class TransactionConfig implements Serializable {
67+
@Serial
6668
private static final long serialVersionUID = -7954949878657177280L;
6769

6870
private static final TransactionConfig EMPTY = builder().build();

driver/src/main/java/org/neo4j/driver/Values.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,12 +570,23 @@ public static Function<Value, Entity> ofEntity() {
570570
/**
571571
* Converts values to {@link Long entity id}.
572572
*
573+
* @deprecated superseded by {@link #ofEntityElementId()}.
573574
* @return a function that returns the id an entity {@link Value}
574575
*/
576+
@Deprecated
575577
public static Function<Value, Long> ofEntityId() {
576578
return val -> val.asEntity().id();
577579
}
578580

581+
/**
582+
* Converts values to {@link String element id}.
583+
*
584+
* @return a function that returns the element id of an entity {@link Value}
585+
*/
586+
public static Function<Value, String> ofEntityElementId() {
587+
return val -> val.asEntity().elementId();
588+
}
589+
579590
/**
580591
* Converts values to {@link Node}.
581592
*

driver/src/main/java/org/neo4j/driver/exceptions/AuthenticationException.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
*/
1919
package org.neo4j.driver.exceptions;
2020

21+
import java.io.Serial;
22+
2123
/**
2224
* Failed to authenticate the driver to the server due to bad credentials provided.
2325
* When this error happens, the error could be recovered by closing the current driver and restart a new driver with
@@ -26,6 +28,9 @@
2628
* @since 1.1
2729
*/
2830
public class AuthenticationException extends SecurityException {
31+
@Serial
32+
private static final long serialVersionUID = 1324352999966240271L;
33+
2934
public AuthenticationException(String code, String message) {
3035
super(code, message);
3136
}

driver/src/main/java/org/neo4j/driver/exceptions/AuthorizationExpiredException.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,17 @@
1818
*/
1919
package org.neo4j.driver.exceptions;
2020

21+
import java.io.Serial;
22+
2123
/**
2224
* The authorization info maintained on the server has expired. The client should reconnect.
2325
* <p>
2426
* Error code: Neo.ClientError.Security.AuthorizationExpired
2527
*/
2628
public class AuthorizationExpiredException extends SecurityException implements RetryableException {
29+
@Serial
30+
private static final long serialVersionUID = 5688002170978405558L;
31+
2732
public static final String DESCRIPTION =
2833
"Authorization information kept on the server has expired, this connection is no longer valid.";
2934

driver/src/main/java/org/neo4j/driver/exceptions/ClientException.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,17 @@
1818
*/
1919
package org.neo4j.driver.exceptions;
2020

21+
import java.io.Serial;
22+
2123
/**
2224
* A <em>ClientException</em> indicates that the client has carried out an operation incorrectly.
2325
* The error code provided can be used to determine further detail for the problem.
2426
* @since 1.0
2527
*/
2628
public class ClientException extends Neo4jException {
29+
@Serial
30+
private static final long serialVersionUID = -6732913155228185887L;
31+
2732
public ClientException(String message) {
2833
super(message);
2934
}

driver/src/main/java/org/neo4j/driver/exceptions/ConnectionReadTimeoutException.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,17 @@
1818
*/
1919
package org.neo4j.driver.exceptions;
2020

21+
import java.io.Serial;
22+
2123
/**
2224
* Indicates that read timed out due to it taking longer than the server-supplied timeout value via the {@code connection.recv_timeout_seconds} configuration
2325
* hint. The server might provide this value to clients to let them know when a given connection may be considered broken if client does not get any
2426
* communication from the server within the specified timeout period. This results in the server being removed from the routing table.
2527
*/
2628
public class ConnectionReadTimeoutException extends ServiceUnavailableException {
29+
@Serial
30+
private static final long serialVersionUID = -9222586212813330140L;
31+
2732
public static final ConnectionReadTimeoutException INSTANCE = new ConnectionReadTimeoutException(
2833
"Connection read timed out due to it taking longer than the server-supplied timeout value via configuration hint.");
2934

driver/src/main/java/org/neo4j/driver/exceptions/DatabaseException.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,17 @@
1818
*/
1919
package org.neo4j.driver.exceptions;
2020

21+
import java.io.Serial;
22+
2123
/**
2224
* A <em>DatabaseException</em> indicates that there is a problem within the underlying database.
2325
* The error code provided can be used to determine further detail for the problem.
2426
* @since 1.0
2527
*/
2628
public class DatabaseException extends Neo4jException {
29+
@Serial
30+
private static final long serialVersionUID = 4591061578560201032L;
31+
2732
public DatabaseException(String code, String message) {
2833
super(code, message);
2934
}

driver/src/main/java/org/neo4j/driver/exceptions/DiscoveryException.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
*/
1919
package org.neo4j.driver.exceptions;
2020

21+
import java.io.Serial;
22+
2123
/**
2224
* An error has happened while getting routing table with a remote server.
2325
* While this error is not fatal and we might be able to recover if we continue trying on another server.
@@ -27,6 +29,9 @@
2729
* If you see this error in your logs, it is safe to ignore if your cluster is temporarily changing structure during that time.
2830
*/
2931
public class DiscoveryException extends Neo4jException {
32+
@Serial
33+
private static final long serialVersionUID = 6711564351333659090L;
34+
3035
public DiscoveryException(String message, Throwable cause) {
3136
super(message, cause);
3237
}

driver/src/main/java/org/neo4j/driver/exceptions/FatalDiscoveryException.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,17 @@
1818
*/
1919
package org.neo4j.driver.exceptions;
2020

21+
import java.io.Serial;
22+
2123
/**
2224
* This error indicate a fatal problem to obtain routing tables such as the routing table for a specified database does not exist.
2325
* This exception should not be retried.
2426
* @since 4.0
2527
*/
2628
public class FatalDiscoveryException extends ClientException {
29+
@Serial
30+
private static final long serialVersionUID = -2831830142554054420L;
31+
2732
public FatalDiscoveryException(String message) {
2833
super(message);
2934
}

driver/src/main/java/org/neo4j/driver/exceptions/Neo4jException.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@
1818
*/
1919
package org.neo4j.driver.exceptions;
2020

21+
import java.io.Serial;
22+
2123
/**
2224
* This is the base class for Neo4j exceptions.
2325
*
2426
* @since 1.0
2527
*/
2628
public class Neo4jException extends RuntimeException {
29+
@Serial
2730
private static final long serialVersionUID = -80579062276712566L;
2831

2932
private final String code;

driver/src/main/java/org/neo4j/driver/exceptions/NoSuchRecordException.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
package org.neo4j.driver.exceptions;
2020

21+
import java.io.Serial;
2122
import java.util.NoSuchElementException;
2223

2324
/**
@@ -28,6 +29,7 @@
2829
* @since 1.0
2930
*/
3031
public class NoSuchRecordException extends NoSuchElementException {
32+
@Serial
3133
private static final long serialVersionUID = 9091962868264042491L;
3234

3335
public NoSuchRecordException(String message) {

driver/src/main/java/org/neo4j/driver/exceptions/ProtocolException.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,16 @@
1818
*/
1919
package org.neo4j.driver.exceptions;
2020

21+
import java.io.Serial;
22+
2123
/**
2224
* A signal that the contract for client-server communication has broken down.
2325
* The user should contact support and cannot resolve this his or herself.
2426
*/
2527
public class ProtocolException extends Neo4jException {
28+
@Serial
29+
private static final long serialVersionUID = -6806924452045883275L;
30+
2631
private static final String CODE = "Protocol violation: ";
2732

2833
public ProtocolException(String message) {

driver/src/main/java/org/neo4j/driver/exceptions/ResultConsumedException.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
package org.neo4j.driver.exceptions;
2020

21+
import java.io.Serial;
2122
import org.neo4j.driver.QueryRunner;
2223

2324
/**
@@ -26,6 +27,9 @@
2627
* the {@link QueryRunner} where the resources are created has already been closed.
2728
*/
2829
public class ResultConsumedException extends ClientException {
30+
@Serial
31+
private static final long serialVersionUID = 944999841543178703L;
32+
2933
public ResultConsumedException(String message) {
3034
super(message);
3135
}

driver/src/main/java/org/neo4j/driver/exceptions/SecurityException.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,18 @@
1818
*/
1919
package org.neo4j.driver.exceptions;
2020

21+
import java.io.Serial;
22+
2123
/**
2224
* Failed to communicate with the server due to security errors.
2325
* When this type of error happens, the security cause of the error should be fixed to ensure the safety of your data.
2426
* Restart of server/driver/cluster might be required to recover from this error.
2527
* @since 1.1
2628
*/
2729
public class SecurityException extends ClientException {
30+
@Serial
31+
private static final long serialVersionUID = -5964665406806523214L;
32+
2833
public SecurityException(String code, String message) {
2934
super(code, message);
3035
}

driver/src/main/java/org/neo4j/driver/exceptions/ServiceUnavailableException.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,17 @@
1818
*/
1919
package org.neo4j.driver.exceptions;
2020

21+
import java.io.Serial;
22+
2123
/**
2224
* An <em>ServiceUnavailableException</em> indicates that the driver cannot communicate with the cluster.
2325
*
2426
* @since 1.1
2527
*/
2628
public class ServiceUnavailableException extends Neo4jException implements RetryableException {
29+
@Serial
30+
private static final long serialVersionUID = 8316077882191697974L;
31+
2732
public ServiceUnavailableException(String message) {
2833
super(message);
2934
}

driver/src/main/java/org/neo4j/driver/exceptions/SessionExpiredException.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,18 @@
1818
*/
1919
package org.neo4j.driver.exceptions;
2020

21+
import java.io.Serial;
22+
2123
/**
2224
* A <em>SessionExpiredException</em> indicates that the session can no longer satisfy the criteria under which it was acquired, e.g. a server no longer accepts
2325
* write requests. A new session needs to be acquired from the driver and all actions taken on the expired session must be replayed.
2426
*
2527
* @since 1.1
2628
*/
2729
public class SessionExpiredException extends Neo4jException implements RetryableException {
30+
@Serial
31+
private static final long serialVersionUID = 843176371236755724L;
32+
2833
public SessionExpiredException(String message) {
2934
super(message);
3035
}

driver/src/main/java/org/neo4j/driver/exceptions/TokenExpiredException.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
*/
1919
package org.neo4j.driver.exceptions;
2020

21+
import java.io.Serial;
22+
2123
/**
2224
* The provided token has expired.
2325
* <p>
@@ -26,6 +28,9 @@
2628
* Error code: Neo.ClientError.Security.TokenExpired
2729
*/
2830
public class TokenExpiredException extends SecurityException {
31+
@Serial
32+
private static final long serialVersionUID = -5593851859769531234L;
33+
2934
public TokenExpiredException(String code, String message) {
3035
super(code, message);
3136
}

driver/src/main/java/org/neo4j/driver/exceptions/TransactionNestingException.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,15 @@
1818
*/
1919
package org.neo4j.driver.exceptions;
2020

21+
import java.io.Serial;
22+
2123
/**
2224
* This exception indicates a user is nesting new transaction with an on-going transaction (unmanaged and/or auto-commit).
2325
*/
2426
public class TransactionNestingException extends ClientException {
27+
@Serial
28+
private static final long serialVersionUID = -8264319542004457065L;
29+
2530
public TransactionNestingException(String message) {
2631
super(message);
2732
}

driver/src/main/java/org/neo4j/driver/exceptions/TransientException.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,18 @@
1818
*/
1919
package org.neo4j.driver.exceptions;
2020

21+
import java.io.Serial;
22+
2123
/**
2224
* A <em>TransientException</em> signals a temporary fault that may be worked around by retrying. The error code provided can be used to determine further
2325
* detail for the problem.
2426
*
2527
* @since 1.0
2628
*/
2729
public class TransientException extends Neo4jException implements RetryableException {
30+
@Serial
31+
private static final long serialVersionUID = -2744576986358599923L;
32+
2833
public TransientException(String code, String message) {
2934
super(code, message);
3035
}

0 commit comments

Comments
 (0)