Skip to content

Make eligible field final and refactor throws #1452

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

Merged
merged 1 commit into from
Jul 11, 2023
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
2 changes: 1 addition & 1 deletion bundle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver-parent</artifactId>
<version>5.10-SNAPSHOT</version>
<version>5.11-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion driver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver-parent</artifactId>
<version>5.10-SNAPSHOT</version>
<version>5.11-SNAPSHOT</version>
</parent>

<artifactId>neo4j-java-driver</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class SingleDatabaseRoutingProcedureRunner implements RoutingProcedureRun
static final String GET_ROUTING_TABLE = "CALL dbms.cluster.routing.getRoutingTable($" + ROUTING_CONTEXT + ")";

final RoutingContext context;
private Logging logging;
private final Logging logging;

public SingleDatabaseRoutingProcedureRunner(RoutingContext context, Logging logging) {
this.context = context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* This is the logging factory to delegate netty's logging to our logging system
*/
public class NettyLogging extends InternalLoggerFactory {
private Logging logging;
private final Logging logging;

public NettyLogging(Logging logging) {
this.logging = logging;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public class PackStream {
private PackStream() {}

public static class Packer {
private PackOutput out;
private final PackOutput out;

public Packer(PackOutput out) {
this.out = out;
Expand Down Expand Up @@ -337,7 +337,7 @@ public void packStructHeader(int size, byte signature) throws IOException {
}

public static class Unpacker {
private PackInput in;
private final PackInput in;

public Unpacker(PackInput in) {
this.in = in;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.neo4j.driver.summary.DatabaseInfo;

public class InternalDatabaseInfo implements DatabaseInfo {
public static DatabaseInfo DEFAULT_DATABASE_INFO = new InternalDatabaseInfo(null);
public static final DatabaseInfo DEFAULT_DATABASE_INFO = new InternalDatabaseInfo(null);

private final String name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ final class Target_org_neo4j_driver_internal_DriverFactory {
* @return A metrics provider, never null
*/
@Substitute
@SuppressWarnings("ProtectedMemberInFinalClass")
protected static MetricsProvider getOrCreateMetricsProvider(Config config, Clock clock) {
var metricsAdapter = config.metricsAdapter();
if (metricsAdapter == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
* @see Type
*/
public class InternalTypeSystem implements TypeSystem {
public static InternalTypeSystem TYPE_SYSTEM = new InternalTypeSystem();
public static final InternalTypeSystem TYPE_SYSTEM = new InternalTypeSystem();

private final TypeRepresentation anyType = constructType(ANY);
private final TypeRepresentation booleanType = constructType(BOOLEAN);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ public static <T> BiConsumer<T, Throwable> futureCompletingConsumer(CompletableF
}

private static class CompletionResult<T> {
T value;
Throwable error;
final T value;
final Throwable error;

CompletionResult(T value, Throwable error) {
this.value = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ private BooleanValue() {
// do nothing
}

public static BooleanValue TRUE = new TrueValue();
public static BooleanValue FALSE = new FalseValue();
public static final BooleanValue TRUE = new TrueValue();
public static final BooleanValue FALSE = new FalseValue();

public static BooleanValue fromBoolean(boolean value) {
return value ? TRUE : FALSE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ private String createLocalIrisData(Session session) throws IOException {
return neo4j.addImportFile("iris", ".csv", IRIS_DATA);
}

private static String[] IRIS_CLASS_NAMES = new String[] {"Iris-setosa", "Iris-versicolor", "Iris-virginica"};
private static final String[] IRIS_CLASS_NAMES = new String[] {"Iris-setosa", "Iris-versicolor", "Iris-virginica"};

private static String IRIS_DATA =
private static final String IRIS_DATA =
"sepal_length,sepal_width,petal_length,petal_width,class_name\n" + "5.1,3.5,1.4,0.2,Iris-setosa\n"
+ "4.9,3.0,1.4,0.2,Iris-setosa\n"
+ "4.7,3.2,1.3,0.2,Iris-setosa\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class MetricsIT {
static final DatabaseExtension neo4j = new DatabaseExtension();

private Driver driver;
private MeterRegistry meterRegistry = new SimpleMeterRegistry();
private final MeterRegistry meterRegistry = new SimpleMeterRegistry();

@BeforeEach
void createDriver() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void testCustomSecurityPlanUsed() {
}

private static class SecurityPlanCapturingDriverFactory extends DriverFactory {
List<SecurityPlan> capturedSecurityPlans = new ArrayList<>();
final List<SecurityPlan> capturedSecurityPlans = new ArrayList<>();

@Override
protected InternalDriver createDriver(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
import org.neo4j.driver.exceptions.ConnectionReadTimeoutException;

public class ConnectionReadTimeoutHandlerTest {
ConnectionReadTimeoutHandler handler = new ConnectionReadTimeoutHandler(15L, TimeUnit.SECONDS);
ChannelHandlerContext context = mock(ChannelHandlerContext.class);
final ConnectionReadTimeoutHandler handler = new ConnectionReadTimeoutHandler(15L, TimeUnit.SECONDS);
final ChannelHandlerContext context = mock(ChannelHandlerContext.class);

@Test
void shouldFireConnectionReadTimeoutExceptionAndCloseChannelOnReadTimeOutOnce() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import org.neo4j.driver.internal.logging.ConsoleLogging.ConsoleLogger;

class ConsoleLoggingTest {
private static ByteArrayOutputStream out = new ByteArrayOutputStream();
private static final ByteArrayOutputStream out = new ByteArrayOutputStream();
private static PrintStream sysErr;

@BeforeAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
import org.neo4j.driver.internal.util.messaging.MemorizingInboundMessageDispatcher;

class MessageFormatTest {
public MessageFormat format = new MessageFormatV3();
public final MessageFormat format = new MessageFormatV3();

@Test
void shouldUnpackAllResponses() throws Throwable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* It's done on this way to make easy to replace the implementation and still getting the same behaviour.
*/
class MessageFormatV3Test {
private static MessageFormat messageFormat = BoltProtocolV3.INSTANCE.createMessageFormat();
private static final MessageFormat messageFormat = BoltProtocolV3.INSTANCE.createMessageFormat();

@Test
void shouldCreateCorrectWriter() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@

public final class BoltProtocolV4Test {

protected static final String QUERY_TEXT = "RETURN $x";
protected static final Map<String, Value> PARAMS = singletonMap("x", value(42));
protected static final Query QUERY = new Query(QUERY_TEXT, value(PARAMS));
private static final String QUERY_TEXT = "RETURN $x";
private static final Map<String, Value> PARAMS = singletonMap("x", value(42));
private static final Query QUERY = new Query(QUERY_TEXT, value(PARAMS));

protected final BoltProtocol protocol = createProtocol();
private final BoltProtocol protocol = createProtocol();
private final EmbeddedChannel channel = new EmbeddedChannel();
private final InboundMessageDispatcher messageDispatcher = new InboundMessageDispatcher(channel, Logging.none());

Expand Down Expand Up @@ -400,7 +400,7 @@ private static InternalAuthToken dummyAuthToken() {
return (InternalAuthToken) AuthTokens.basic("hello", "world");
}

protected void testFailedRunInAutoCommitTxWithWaitingForResponse(
private void testFailedRunInAutoCommitTxWithWaitingForResponse(
Set<Bookmark> bookmarks, TransactionConfig config, AccessMode mode) throws Exception {
// Given
var connection = connectionMock(mode, protocol);
Expand Down Expand Up @@ -434,7 +434,7 @@ protected void testFailedRunInAutoCommitTxWithWaitingForResponse(
assertSame(error, actual);
}

protected void testSuccessfulRunInAutoCommitTxWithWaitingForResponse(
private void testSuccessfulRunInAutoCommitTxWithWaitingForResponse(
Set<Bookmark> bookmarks, TransactionConfig config, AccessMode mode) throws Exception {
// Given
var connection = connectionMock(mode, protocol);
Expand Down Expand Up @@ -465,8 +465,7 @@ protected void testSuccessfulRunInAutoCommitTxWithWaitingForResponse(
assertNotNull(cursorFuture.get());
}

protected void testRunInUnmanagedTransactionAndWaitForRunResponse(boolean success, AccessMode mode)
throws Exception {
private void testRunInUnmanagedTransactionAndWaitForRunResponse(boolean success, AccessMode mode) throws Exception {
// Given
var connection = connectionMock(mode, protocol);

Expand Down Expand Up @@ -497,7 +496,7 @@ connection, QUERY, mock(UnmanagedTransaction.class), UNLIMITED_FETCH_SIZE)
}
}

protected void testRunAndWaitForRunResponse(boolean autoCommitTx, TransactionConfig config, AccessMode mode)
private void testRunAndWaitForRunResponse(boolean autoCommitTx, TransactionConfig config, AccessMode mode)
throws Exception {
// Given
var connection = connectionMock(mode, protocol);
Expand Down Expand Up @@ -534,7 +533,7 @@ connection, QUERY, mock(UnmanagedTransaction.class), UNLIMITED_FETCH_SIZE)
assertNotNull(cursorFuture.get());
}

protected void testDatabaseNameSupport(boolean autoCommitTx) {
private void testDatabaseNameSupport(boolean autoCommitTx) {
var connection = connectionMock("foo", protocol);
if (autoCommitTx) {
var factory = protocol.runInAutoCommitTransaction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@
import org.neo4j.driver.internal.spi.ResponseHandler;

public final class BoltProtocolV41Test {
protected static final String QUERY_TEXT = "RETURN $x";
protected static final Map<String, Value> PARAMS = singletonMap("x", value(42));
protected static final Query QUERY = new Query(QUERY_TEXT, value(PARAMS));
private static final String QUERY_TEXT = "RETURN $x";
private static final Map<String, Value> PARAMS = singletonMap("x", value(42));
private static final Query QUERY = new Query(QUERY_TEXT, value(PARAMS));

protected final BoltProtocol protocol = createProtocol();
private final BoltProtocol protocol = createProtocol();
private final EmbeddedChannel channel = new EmbeddedChannel();
private final InboundMessageDispatcher messageDispatcher = new InboundMessageDispatcher(channel, Logging.none());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@
import org.neo4j.driver.internal.spi.ResponseHandler;

public final class BoltProtocolV42Test {
protected static final String QUERY_TEXT = "RETURN $x";
protected static final Map<String, Value> PARAMS = singletonMap("x", value(42));
protected static final Query QUERY = new Query(QUERY_TEXT, value(PARAMS));
private static final String QUERY_TEXT = "RETURN $x";
private static final Map<String, Value> PARAMS = singletonMap("x", value(42));
private static final Query QUERY = new Query(QUERY_TEXT, value(PARAMS));

protected final BoltProtocol protocol = createProtocol();
private final BoltProtocol protocol = createProtocol();
private final EmbeddedChannel channel = new EmbeddedChannel();
private final InboundMessageDispatcher messageDispatcher = new InboundMessageDispatcher(channel, Logging.none());

Expand All @@ -111,7 +111,7 @@ public final class BoltProtocolV42Test {
.withMetadata(singletonMap("key", value(42)))
.build();

protected BoltProtocol createProtocol() {
private BoltProtocol createProtocol() {
return BoltProtocolV42.INSTANCE;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@
import org.neo4j.driver.internal.spi.ResponseHandler;

public final class BoltProtocolV43Test {
protected static final String QUERY_TEXT = "RETURN $x";
protected static final Map<String, Value> PARAMS = singletonMap("x", value(42));
protected static final Query QUERY = new Query(QUERY_TEXT, value(PARAMS));
private static final String QUERY_TEXT = "RETURN $x";
private static final Map<String, Value> PARAMS = singletonMap("x", value(42));
private static final Query QUERY = new Query(QUERY_TEXT, value(PARAMS));

protected final BoltProtocol protocol = createProtocol();
private final BoltProtocol protocol = createProtocol();
private final EmbeddedChannel channel = new EmbeddedChannel();
private final InboundMessageDispatcher messageDispatcher = new InboundMessageDispatcher(channel, Logging.none());

Expand All @@ -110,7 +110,7 @@ public final class BoltProtocolV43Test {
.withMetadata(singletonMap("key", value(42)))
.build();

protected BoltProtocol createProtocol() {
private BoltProtocol createProtocol() {
return BoltProtocolV43.INSTANCE;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ class MicrometerConnectionPoolMetricsTest {
BoltServerAddress address;
ConnectionPool pool;
MeterRegistry registry;
AtomicInteger inUse = new AtomicInteger(0);
IntSupplier inUseSupplier = inUse::get;
AtomicInteger idle = new AtomicInteger(0);
IntSupplier idleSupplier = idle::get;
final AtomicInteger inUse = new AtomicInteger(0);
final IntSupplier inUseSupplier = inUse::get;
final AtomicInteger idle = new AtomicInteger(0);
final IntSupplier idleSupplier = idle::get;

@BeforeEach
void beforeEach() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/
public class BufferedChannelInput implements PackInput {
private final ByteBuffer buffer;
private ReadableByteChannel channel;
private final ReadableByteChannel channel;
private static final int DEFAULT_BUFFER_CAPACITY = 8192;

public BufferedChannelInput(ReadableByteChannel ch) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.neo4j.driver.types.TypeSystem;

class BooleanValueTest {
private TypeSystem typeSystem = InternalTypeSystem.TYPE_SYSTEM;
private final TypeSystem typeSystem = InternalTypeSystem.TYPE_SYSTEM;

@Test
void testBooleanTrue() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
class BytesValueTest {
private static final byte[] TEST_BYTES = "0123".getBytes();

private TypeSystem typeSystem = InternalTypeSystem.TYPE_SYSTEM;
private final TypeSystem typeSystem = InternalTypeSystem.TYPE_SYSTEM;

@Test
void testBytesValue() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.neo4j.driver.types.TypeSystem;

class FloatValueTest {
private TypeSystem typeSystem = InternalTypeSystem.TYPE_SYSTEM;
private final TypeSystem typeSystem = InternalTypeSystem.TYPE_SYSTEM;

@Test
void testZeroFloatValue() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.neo4j.driver.types.TypeSystem;

class IntegerValueTest {
private TypeSystem typeSystem = InternalTypeSystem.TYPE_SYSTEM;
private final TypeSystem typeSystem = InternalTypeSystem.TYPE_SYSTEM;

@Test
void testZeroIntegerValue() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.neo4j.driver.types.TypeSystem;

class StringValueTest {
private TypeSystem typeSystem = InternalTypeSystem.TYPE_SYSTEM;
private final TypeSystem typeSystem = InternalTypeSystem.TYPE_SYSTEM;

@Test
void testStringValue() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.neo4j.driver.internal.util.Futures;

public class AsyncWriteQuery<C extends AbstractContext> extends AbstractAsyncQuery<C> {
private AbstractStressTestBase<C> stressTest;
private final AbstractStressTestBase<C> stressTest;

public AsyncWriteQuery(AbstractStressTestBase<C> stressTest, Driver driver, boolean useBookmark) {
super(driver, useBookmark);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.neo4j.driver.internal.util.Futures;

public class AsyncWriteQueryInTx<C extends AbstractContext> extends AbstractAsyncQuery<C> {
private AbstractStressTestBase<C> stressTest;
private final AbstractStressTestBase<C> stressTest;

public AsyncWriteQueryInTx(AbstractStressTestBase<C> stressTest, Driver driver, boolean useBookmark) {
super(driver, useBookmark);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.neo4j.driver.summary.ResultSummary;

public class BlockingWriteQuery<C extends AbstractContext> extends AbstractBlockingQuery<C> {
private AbstractStressTestBase<C> stressTest;
private final AbstractStressTestBase<C> stressTest;

public BlockingWriteQuery(AbstractStressTestBase<C> stressTest, Driver driver, boolean useBookmark) {
super(driver, useBookmark);
Expand Down
Loading