Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable compilation failures on warnings for driver module main sources #1275

Merged
merged 1 commit into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions driver/clirr-ignored-differences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -334,4 +334,10 @@
<method>java.lang.String neo4jErrorCode()</method>
</difference>

<difference>
<className>org/neo4j/driver/QueryRunner</className>
<differenceType>7012</differenceType>
<method>void close()</method>
</difference>

</differences>
2 changes: 2 additions & 0 deletions driver/src/main/java/org/neo4j/driver/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import static org.neo4j.driver.internal.logging.DevNullLogging.DEV_NULL_LOGGING;

import java.io.File;
import java.io.Serial;
import java.io.Serializable;
import java.net.InetAddress;
import java.util.ArrayList;
Expand Down Expand Up @@ -70,6 +71,7 @@
*/
@Immutable
public class Config implements Serializable {
@Serial
private static final long serialVersionUID = -4496545746399601108L;

private static final Config EMPTY = builder().build();
Expand Down
5 changes: 4 additions & 1 deletion driver/src/main/java/org/neo4j/driver/QueryRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@
*
* @since 1.0
*/
public interface QueryRunner extends SimpleQueryRunner, AutoCloseable {}
public interface QueryRunner extends SimpleQueryRunner, AutoCloseable {
@Override
void close() throws RuntimeException;
}
2 changes: 2 additions & 0 deletions driver/src/main/java/org/neo4j/driver/SessionConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import static java.util.Objects.requireNonNull;
import static org.neo4j.driver.internal.handlers.pulln.FetchSizeUtil.assertValidFetchSize;

import java.io.Serial;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Objects;
Expand All @@ -34,6 +35,7 @@
* The session configurations used to configure a session.
*/
public class SessionConfig implements Serializable {
@Serial
private static final long serialVersionUID = 5773462156979050657L;

private static final SessionConfig EMPTY = builder().build();
Expand Down
2 changes: 2 additions & 0 deletions driver/src/main/java/org/neo4j/driver/TransactionConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import static java.util.Objects.requireNonNull;
import static org.neo4j.driver.internal.util.Preconditions.checkArgument;

import java.io.Serial;
import java.io.Serializable;
import java.time.Duration;
import java.util.HashMap;
Expand Down Expand Up @@ -63,6 +64,7 @@
* @see Session
*/
public class TransactionConfig implements Serializable {
@Serial
private static final long serialVersionUID = -7954949878657177280L;

private static final TransactionConfig EMPTY = builder().build();
Expand Down
11 changes: 11 additions & 0 deletions driver/src/main/java/org/neo4j/driver/Values.java
Original file line number Diff line number Diff line change
Expand Up @@ -570,12 +570,23 @@ public static Function<Value, Entity> ofEntity() {
/**
* Converts values to {@link Long entity id}.
*
* @deprecated superseded by {@link #ofEntityElementId()}.
* @return a function that returns the id an entity {@link Value}
*/
@Deprecated
public static Function<Value, Long> ofEntityId() {
return val -> val.asEntity().id();
}

/**
* Converts values to {@link String element id}.
*
* @return a function that returns the element id of an entity {@link Value}
*/
public static Function<Value, String> ofEntityElementId() {
return val -> val.asEntity().elementId();
}

/**
* Converts values to {@link Node}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package org.neo4j.driver.exceptions;

import java.io.Serial;

/**
* Failed to authenticate the driver to the server due to bad credentials provided.
* When this error happens, the error could be recovered by closing the current driver and restart a new driver with
Expand All @@ -26,6 +28,9 @@
* @since 1.1
*/
public class AuthenticationException extends SecurityException {
@Serial
private static final long serialVersionUID = 1324352999966240271L;

public AuthenticationException(String code, String message) {
super(code, message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@
*/
package org.neo4j.driver.exceptions;

import java.io.Serial;

/**
* The authorization info maintained on the server has expired. The client should reconnect.
* <p>
* Error code: Neo.ClientError.Security.AuthorizationExpired
*/
public class AuthorizationExpiredException extends SecurityException implements RetryableException {
@Serial
private static final long serialVersionUID = 5688002170978405558L;

public static final String DESCRIPTION =
"Authorization information kept on the server has expired, this connection is no longer valid.";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@
*/
package org.neo4j.driver.exceptions;

import java.io.Serial;

/**
* A <em>ClientException</em> indicates that the client has carried out an operation incorrectly.
* The error code provided can be used to determine further detail for the problem.
* @since 1.0
*/
public class ClientException extends Neo4jException {
@Serial
private static final long serialVersionUID = -6732913155228185887L;

public ClientException(String message) {
super(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@
*/
package org.neo4j.driver.exceptions;

import java.io.Serial;

/**
* Indicates that read timed out due to it taking longer than the server-supplied timeout value via the {@code connection.recv_timeout_seconds} configuration
* 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
* communication from the server within the specified timeout period. This results in the server being removed from the routing table.
*/
public class ConnectionReadTimeoutException extends ServiceUnavailableException {
@Serial
private static final long serialVersionUID = -9222586212813330140L;

public static final ConnectionReadTimeoutException INSTANCE = new ConnectionReadTimeoutException(
"Connection read timed out due to it taking longer than the server-supplied timeout value via configuration hint.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@
*/
package org.neo4j.driver.exceptions;

import java.io.Serial;

/**
* A <em>DatabaseException</em> indicates that there is a problem within the underlying database.
* The error code provided can be used to determine further detail for the problem.
* @since 1.0
*/
public class DatabaseException extends Neo4jException {
@Serial
private static final long serialVersionUID = 4591061578560201032L;

public DatabaseException(String code, String message) {
super(code, message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package org.neo4j.driver.exceptions;

import java.io.Serial;

/**
* An error has happened while getting routing table with a remote server.
* While this error is not fatal and we might be able to recover if we continue trying on another server.
Expand All @@ -27,6 +29,9 @@
* If you see this error in your logs, it is safe to ignore if your cluster is temporarily changing structure during that time.
*/
public class DiscoveryException extends Neo4jException {
@Serial
private static final long serialVersionUID = 6711564351333659090L;

public DiscoveryException(String message, Throwable cause) {
super(message, cause);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@
*/
package org.neo4j.driver.exceptions;

import java.io.Serial;

/**
* This error indicate a fatal problem to obtain routing tables such as the routing table for a specified database does not exist.
* This exception should not be retried.
* @since 4.0
*/
public class FatalDiscoveryException extends ClientException {
@Serial
private static final long serialVersionUID = -2831830142554054420L;

public FatalDiscoveryException(String message) {
super(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@
*/
package org.neo4j.driver.exceptions;

import java.io.Serial;

/**
* This is the base class for Neo4j exceptions.
*
* @since 1.0
*/
public class Neo4jException extends RuntimeException {
@Serial
private static final long serialVersionUID = -80579062276712566L;

private final String code;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.neo4j.driver.exceptions;

import java.io.Serial;
import java.util.NoSuchElementException;

/**
Expand All @@ -28,6 +29,7 @@
* @since 1.0
*/
public class NoSuchRecordException extends NoSuchElementException {
@Serial
private static final long serialVersionUID = 9091962868264042491L;

public NoSuchRecordException(String message) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@
*/
package org.neo4j.driver.exceptions;

import java.io.Serial;

/**
* A signal that the contract for client-server communication has broken down.
* The user should contact support and cannot resolve this his or herself.
*/
public class ProtocolException extends Neo4jException {
@Serial
private static final long serialVersionUID = -6806924452045883275L;

private static final String CODE = "Protocol violation: ";

public ProtocolException(String message) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.neo4j.driver.exceptions;

import java.io.Serial;
import org.neo4j.driver.QueryRunner;

/**
Expand All @@ -26,6 +27,9 @@
* the {@link QueryRunner} where the resources are created has already been closed.
*/
public class ResultConsumedException extends ClientException {
@Serial
private static final long serialVersionUID = 944999841543178703L;

public ResultConsumedException(String message) {
super(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@
*/
package org.neo4j.driver.exceptions;

import java.io.Serial;

/**
* Failed to communicate with the server due to security errors.
* When this type of error happens, the security cause of the error should be fixed to ensure the safety of your data.
* Restart of server/driver/cluster might be required to recover from this error.
* @since 1.1
*/
public class SecurityException extends ClientException {
@Serial
private static final long serialVersionUID = -5964665406806523214L;

public SecurityException(String code, String message) {
super(code, message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@
*/
package org.neo4j.driver.exceptions;

import java.io.Serial;

/**
* An <em>ServiceUnavailableException</em> indicates that the driver cannot communicate with the cluster.
*
* @since 1.1
*/
public class ServiceUnavailableException extends Neo4jException implements RetryableException {
@Serial
private static final long serialVersionUID = 8316077882191697974L;

public ServiceUnavailableException(String message) {
super(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@
*/
package org.neo4j.driver.exceptions;

import java.io.Serial;

/**
* 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
* write requests. A new session needs to be acquired from the driver and all actions taken on the expired session must be replayed.
*
* @since 1.1
*/
public class SessionExpiredException extends Neo4jException implements RetryableException {
@Serial
private static final long serialVersionUID = 843176371236755724L;

public SessionExpiredException(String message) {
super(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package org.neo4j.driver.exceptions;

import java.io.Serial;

/**
* The provided token has expired.
* <p>
Expand All @@ -26,6 +28,9 @@
* Error code: Neo.ClientError.Security.TokenExpired
*/
public class TokenExpiredException extends SecurityException {
@Serial
private static final long serialVersionUID = -5593851859769531234L;

public TokenExpiredException(String code, String message) {
super(code, message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@
*/
package org.neo4j.driver.exceptions;

import java.io.Serial;

/**
* This exception indicates a user is nesting new transaction with an on-going transaction (unmanaged and/or auto-commit).
*/
public class TransactionNestingException extends ClientException {
@Serial
private static final long serialVersionUID = -8264319542004457065L;

public TransactionNestingException(String message) {
super(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@
*/
package org.neo4j.driver.exceptions;

import java.io.Serial;

/**
* 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
* detail for the problem.
*
* @since 1.0
*/
public class TransientException extends Neo4jException implements RetryableException {
@Serial
private static final long serialVersionUID = -2744576986358599923L;

public TransientException(String code, String message) {
super(code, message);
}
Expand Down
Loading