Skip to content

Commit bde291e

Browse files
committed
Refactoring
1 parent 3b116b9 commit bde291e

File tree

12 files changed

+28
-27
lines changed

12 files changed

+28
-27
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public static AuthToken kerberos(String base64EncodedTicket) {
116116
* A custom authentication token used for doing custom authentication on the server side.
117117
* @param principal this used to identify who this token represents
118118
* @param credentials this is credentials authenticating the principal
119-
* @param realm this is the "realm:, specifying the authentication provider.
119+
* @param realm this is the "realm:", specifying the authentication provider.
120120
* @param scheme this it the authentication scheme, specifying what kind of authentication that should be used
121121
* @return an authentication token that can be used to connect to Neo4j
122122
* @see GraphDatabase#driver(String, AuthToken)
@@ -130,7 +130,7 @@ public static AuthToken custom(String principal, String credentials, String real
130130
* A custom authentication token used for doing custom authentication on the server side.
131131
* @param principal this used to identify who this token represents
132132
* @param credentials this is credentials authenticating the principal
133-
* @param realm this is the "realm:, specifying the authentication provider.
133+
* @param realm this is the "realm:", specifying the authentication provider.
134134
* @param scheme this it the authentication scheme, specifying what kind of authentication that should be used
135135
* @param parameters extra parameters to be sent along the authentication provider.
136136
* @return an authentication token that can be used to connect to Neo4j

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* the database is as up-to-date as the latest transaction referenced by the supplied bookmarks.
3030
* <p>
3131
* Within a session, bookmark propagation is carried out automatically.
32-
* Thus all transactions in a session (both managed and unmanaged) are guaranteed to be carried out one after another.
32+
* Thus, all transactions in a session (both managed and unmanaged) are guaranteed to be carried out one after another.
3333
* <p>
3434
* To opt out of this mechanism for unrelated units of work, applications can use multiple sessions.
3535
*/

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
* and authentication settings are held immutably by the Driver. Should
3636
* different settings be required, a new Driver instance should be created.
3737
* <p>
38-
* A driver maintains a connection pool for each remote Neo4j server. Therefore
38+
* A driver maintains a connection pool for each remote Neo4j server. Therefore,
3939
* the most efficient way to make use of a Driver is to use the same instance
4040
* across the application.
4141
* <p>
@@ -83,7 +83,7 @@ public interface Driver extends AutoCloseable {
8383
BookmarkManager executableQueryBookmarkManager();
8484

8585
/**
86-
* Return a flag to indicate whether or not encryption is used for this driver.
86+
* Return a flag to indicate whether encryption is used for this driver.
8787
*
8888
* @return true if the driver requires encryption, false otherwise
8989
*/

driver/src/main/java/org/neo4j/driver/internal/DriverFactory.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import java.time.Clock;
3232
import java.util.function.Supplier;
3333
import org.neo4j.driver.AuthTokenManager;
34-
import org.neo4j.driver.AuthTokens;
3534
import org.neo4j.driver.Config;
3635
import org.neo4j.driver.Driver;
3736
import org.neo4j.driver.Logging;
@@ -57,7 +56,6 @@
5756
import org.neo4j.driver.internal.retry.RetryLogic;
5857
import org.neo4j.driver.internal.security.SecurityPlan;
5958
import org.neo4j.driver.internal.security.SecurityPlans;
60-
import org.neo4j.driver.internal.security.StaticAuthTokenManager;
6159
import org.neo4j.driver.internal.spi.ConnectionPool;
6260
import org.neo4j.driver.internal.spi.ConnectionProvider;
6361
import org.neo4j.driver.internal.util.DriverInfoUtil;
@@ -96,8 +94,6 @@ public final Driver newInstance(
9694
securityPlan = SecurityPlans.createSecurityPlan(settings, uri.getScheme());
9795
}
9896

99-
authTokenManager = authTokenManager == null ? new StaticAuthTokenManager(AuthTokens.none()) : authTokenManager;
100-
10197
var address = new BoltServerAddress(uri);
10298
var routingSettings = new RoutingSettings(config.routingTablePurgeDelayMillis(), new RoutingContext(uri));
10399

driver/src/test/java/org/neo4j/driver/integration/SessionIT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,6 +1360,7 @@ private static Result updateNodeId(QueryRunner queryRunner, int currentId, int n
13601360
"MATCH (n {id: $currentId}) SET n.id = $newId", parameters("currentId", currentId, "newId", newId));
13611361
}
13621362

1363+
@SuppressWarnings("ConstantValue")
13631364
private static boolean assertOneOfTwoFuturesFailWithDeadlock(Future<Void> future1, Future<Void> future2)
13641365
throws Exception {
13651366
var firstFailed = false;

driver/src/test/java/org/neo4j/driver/integration/reactive/ReactiveSessionIT.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import org.reactivestreams.Subscription;
5757
import reactor.core.publisher.BaseSubscriber;
5858
import reactor.core.publisher.Flux;
59+
import reactor.util.annotation.NonNull;
5960

6061
@EnabledOnNeo4jWith(BOLT_V4)
6162
@ParallelizableIT
@@ -161,7 +162,7 @@ void shouldRollbackResultOnSubscriptionCancellation() {
161162
flowPublisherToFlux(session.run("CREATE ({id: $id})", Map.of("id", nodeId)))
162163
.subscribe(new BaseSubscriber<>() {
163164
@Override
164-
protected void hookOnSubscribe(Subscription subscription) {
165+
protected void hookOnSubscribe(@NonNull Subscription subscription) {
165166
subscription.cancel();
166167
cancellationFuture.complete(null);
167168
}

driver/src/test/java/org/neo4j/driver/integration/reactive/ReactiveStreamsSessionIT.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import reactor.core.publisher.BaseSubscriber;
5555
import reactor.core.publisher.Flux;
5656
import reactor.core.publisher.Mono;
57+
import reactor.util.annotation.NonNull;
5758

5859
@EnabledOnNeo4jWith(BOLT_V4)
5960
@ParallelizableIT
@@ -97,14 +98,14 @@ void shouldReleaseResultsOnSubscriptionCancellation(boolean request) throws Inte
9798
.run("UNWIND range (0,10000) AS x RETURN x")
9899
.subscribe(new BaseSubscriber<>() {
99100
@Override
100-
protected void hookOnSubscribe(Subscription subscription) {
101+
protected void hookOnSubscribe(@NonNull Subscription subscription) {
101102
// use subscription from another thread to avoid immediate cancellation
102103
// within the subscribe method
103104
subscriptionFuture.complete(subscription);
104105
}
105106

106107
@Override
107-
protected void hookOnNext(ReactiveResult result) {
108+
protected void hookOnNext(@NonNull ReactiveResult result) {
108109
Mono.fromDirect(result.consume()).subscribe();
109110
}
110111
});
@@ -150,7 +151,7 @@ void shouldRollbackResultOnSubscriptionCancellation() {
150151

151152
session.run("CREATE ({id: $id})", Map.of("id", nodeId)).subscribe(new BaseSubscriber<>() {
152153
@Override
153-
protected void hookOnSubscribe(Subscription subscription) {
154+
protected void hookOnSubscribe(@NonNull Subscription subscription) {
154155
subscription.cancel();
155156
cancellationFuture.complete(null);
156157
}

driver/src/test/java/org/neo4j/driver/internal/InternalPathTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ void shouldNotBeAbleToCreatePathWithEvenNumberOfEntities() {
128128

129129
@Test
130130
void shouldNotBeAbleToCreatePathWithNullEntities() {
131-
InternalNode nullNode = null;
132-
assertThrows(IllegalArgumentException.class, () -> new InternalPath(nullNode));
131+
assertThrows(IllegalArgumentException.class, () -> new InternalPath((InternalNode) null));
133132
}
134133

135134
@Test

driver/src/test/java/org/neo4j/driver/internal/SecuritySettingsTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void shouldReadBackChangedEncryption() throws IOException, ClassNotFoundExceptio
7373
var verify = TestUtil.serializeAndReadBack(securitySettings, SecuritySettings.class);
7474

7575
assertTrue(isCustomized(verify));
76-
assertTrue(securitySettings.encrypted());
76+
assertTrue(verify.encrypted());
7777
}
7878

7979
@Test
@@ -94,10 +94,10 @@ void shouldReadBackChangedStrategey() throws IOException, ClassNotFoundException
9494
var verify = TestUtil.serializeAndReadBack(securitySettings, SecuritySettings.class);
9595

9696
assertTrue(isCustomized(verify));
97-
assertFalse(securitySettings.encrypted());
97+
assertFalse(verify.encrypted());
9898
assertEquals(
9999
Config.TrustStrategy.trustAllCertificates().strategy(),
100-
securitySettings.trustStrategy().strategy());
100+
verify.trustStrategy().strategy());
101101
}
102102

103103
@Test
@@ -119,11 +119,11 @@ void shouldReadBackChangedCertFile() throws IOException, ClassNotFoundException
119119
var verify = TestUtil.serializeAndReadBack(securitySettings, SecuritySettings.class);
120120

121121
assertTrue(isCustomized(verify));
122-
assertFalse(securitySettings.encrypted());
122+
assertFalse(verify.encrypted());
123123
assertEquals(
124124
Config.TrustStrategy.trustCustomCertificateSignedBy(new File("some.cert"))
125125
.strategy(),
126-
securitySettings.trustStrategy().strategy());
126+
verify.trustStrategy().strategy());
127127
}
128128
}
129129
}

driver/src/test/java/org/neo4j/driver/internal/reactive/RxUtilsTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.reactivestreams.Subscription;
3636
import reactor.core.publisher.BaseSubscriber;
3737
import reactor.test.StepVerifier;
38+
import reactor.util.annotation.NonNull;
3839

3940
class RxUtilsTest {
4041
@Test
@@ -94,7 +95,7 @@ void singleItemPublisherShouldHandleCancellationAfterRequestProcessingBegins() {
9495
// WHEN
9596
publisher.subscribe(new BaseSubscriber<>() {
9697
@Override
97-
protected void hookOnSubscribe(Subscription subscription) {
98+
protected void hookOnSubscribe(@NonNull Subscription subscription) {
9899
subscription.request(1);
99100
supplierInvokedFuture.thenAccept(ignored -> {
100101
subscription.cancel();

driver/src/test/java/org/neo4j/driver/internal/util/IterablesTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ void shouldThrowWhenNegativeLinkedHashMapSizeGiven() {
4949
}
5050

5151
@Test
52+
@SuppressWarnings("ConstantValue")
5253
void shouldReturnEmptyQueue() {
5354
var queue = Iterables.emptyQueue();
5455
assertEquals(0, queue.size());

testkit-backend/src/main/java/neo4j/org/testkit/backend/RxBufferedSubscriber.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import reactor.core.publisher.FluxSink;
3030
import reactor.core.publisher.Mono;
3131
import reactor.core.publisher.MonoSink;
32+
import reactor.util.annotation.NonNull;
3233

3334
/**
3435
* Buffered subscriber for testing purposes.
@@ -87,12 +88,12 @@ public Mono<T> next() {
8788
}
8889

8990
@Override
90-
protected void hookOnSubscribe(Subscription subscription) {
91+
protected void hookOnSubscribe(@NonNull Subscription subscription) {
9192
subscriptionFuture.complete(subscription);
9293
}
9394

9495
@Override
95-
protected void hookOnNext(T value) {
96+
protected void hookOnNext(@NonNull T value) {
9697
executeWithLock(lock, () -> pendingItems--);
9798
itemsSink.next(value);
9899
}
@@ -103,7 +104,7 @@ protected void hookOnComplete() {
103104
}
104105

105106
@Override
106-
protected void hookOnError(Throwable throwable) {
107+
protected void hookOnError(@NonNull Throwable throwable) {
107108
itemsSink.error(throwable);
108109
}
109110

@@ -163,12 +164,12 @@ public void requestNext(MonoSink<T> sink) {
163164
}
164165

165166
@Override
166-
protected void hookOnSubscribe(Subscription subscription) {
167+
protected void hookOnSubscribe(@NonNull Subscription subscription) {
167168
// left empty to prevent requesting signals immediately
168169
}
169170

170171
@Override
171-
protected void hookOnNext(T value) {
172+
protected void hookOnNext(@NonNull T value) {
172173
var sink = executeWithLock(lock, () -> {
173174
emitted = true;
174175
return this.sink;
@@ -188,7 +189,7 @@ protected void hookOnComplete() {
188189
}
189190

190191
@Override
191-
protected void hookOnError(Throwable throwable) {
192+
protected void hookOnError(@NonNull Throwable throwable) {
192193
var sink = executeWithLock(lock, () -> {
193194
completionFuture.completeExceptionally(throwable);
194195
return !emitted ? this.sink : null;

0 commit comments

Comments
 (0)