Skip to content

Refactoring #1470

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 26, 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
4 changes: 2 additions & 2 deletions driver/src/main/java/org/neo4j/driver/AuthTokens.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public static AuthToken kerberos(String base64EncodedTicket) {
* A custom authentication token used for doing custom authentication on the server side.
* @param principal this used to identify who this token represents
* @param credentials this is credentials authenticating the principal
* @param realm this is the "realm:, specifying the authentication provider.
* @param realm this is the "realm:", specifying the authentication provider.
* @param scheme this it the authentication scheme, specifying what kind of authentication that should be used
* @return an authentication token that can be used to connect to Neo4j
* @see GraphDatabase#driver(String, AuthToken)
Expand All @@ -130,7 +130,7 @@ public static AuthToken custom(String principal, String credentials, String real
* A custom authentication token used for doing custom authentication on the server side.
* @param principal this used to identify who this token represents
* @param credentials this is credentials authenticating the principal
* @param realm this is the "realm:, specifying the authentication provider.
* @param realm this is the "realm:", specifying the authentication provider.
* @param scheme this it the authentication scheme, specifying what kind of authentication that should be used
* @param parameters extra parameters to be sent along the authentication provider.
* @return an authentication token that can be used to connect to Neo4j
Expand Down
2 changes: 1 addition & 1 deletion driver/src/main/java/org/neo4j/driver/Bookmark.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* the database is as up-to-date as the latest transaction referenced by the supplied bookmarks.
* <p>
* Within a session, bookmark propagation is carried out automatically.
* Thus all transactions in a session (both managed and unmanaged) are guaranteed to be carried out one after another.
* Thus, all transactions in a session (both managed and unmanaged) are guaranteed to be carried out one after another.
* <p>
* To opt out of this mechanism for unrelated units of work, applications can use multiple sessions.
*/
Expand Down
4 changes: 2 additions & 2 deletions driver/src/main/java/org/neo4j/driver/Driver.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* and authentication settings are held immutably by the Driver. Should
* different settings be required, a new Driver instance should be created.
* <p>
* A driver maintains a connection pool for each remote Neo4j server. Therefore
* A driver maintains a connection pool for each remote Neo4j server. Therefore,
* the most efficient way to make use of a Driver is to use the same instance
* across the application.
* <p>
Expand Down Expand Up @@ -83,7 +83,7 @@ public interface Driver extends AutoCloseable {
BookmarkManager executableQueryBookmarkManager();

/**
* Return a flag to indicate whether or not encryption is used for this driver.
* Return a flag to indicate whether encryption is used for this driver.
*
* @return true if the driver requires encryption, false otherwise
*/
Expand Down
2 changes: 1 addition & 1 deletion driver/src/main/java/org/neo4j/driver/Logger.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* <p>
* Some methods in this interface take a message template together with a list of parameters. These methods are expected to construct the final
* message only if the needed logging level is enabled. Driver expects formatting to be done using {@link String#format(String, Object...)} method.
* Thus all supplied message templates will contain "%s" as parameter placeholders. This is different from all SLF4J-compatible logging frameworks
* Thus, all supplied message templates will contain "%s" as parameter placeholders. This is different from all SLF4J-compatible logging frameworks
* where parameter placeholder is "{}". Implementations of this interface should adapt placeholders from "%s" to "{}", if required.
*/
public interface Logger {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import java.time.Clock;
import java.util.function.Supplier;
import org.neo4j.driver.AuthTokenManager;
import org.neo4j.driver.AuthTokens;
import org.neo4j.driver.Config;
import org.neo4j.driver.Driver;
import org.neo4j.driver.Logging;
Expand All @@ -57,7 +56,6 @@
import org.neo4j.driver.internal.retry.RetryLogic;
import org.neo4j.driver.internal.security.SecurityPlan;
import org.neo4j.driver.internal.security.SecurityPlans;
import org.neo4j.driver.internal.security.StaticAuthTokenManager;
import org.neo4j.driver.internal.spi.ConnectionPool;
import org.neo4j.driver.internal.spi.ConnectionProvider;
import org.neo4j.driver.internal.util.DriverInfoUtil;
Expand Down Expand Up @@ -96,8 +94,6 @@ public final Driver newInstance(
securityPlan = SecurityPlans.createSecurityPlan(settings, uri.getScheme());
}

authTokenManager = authTokenManager == null ? new StaticAuthTokenManager(AuthTokens.none()) : authTokenManager;

var address = new BoltServerAddress(uri);
var routingSettings = new RoutingSettings(config.routingTablePurgeDelayMillis(), new RoutingContext(uri));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,7 @@ private static Result updateNodeId(QueryRunner queryRunner, int currentId, int n
"MATCH (n {id: $currentId}) SET n.id = $newId", parameters("currentId", currentId, "newId", newId));
}

@SuppressWarnings("ConstantValue")
private static boolean assertOneOfTwoFuturesFailWithDeadlock(Future<Void> future1, Future<Void> future2)
throws Exception {
var firstFailed = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import org.reactivestreams.Subscription;
import reactor.core.publisher.BaseSubscriber;
import reactor.core.publisher.Flux;
import reactor.util.annotation.NonNull;

@EnabledOnNeo4jWith(BOLT_V4)
@ParallelizableIT
Expand Down Expand Up @@ -161,7 +162,7 @@ void shouldRollbackResultOnSubscriptionCancellation() {
flowPublisherToFlux(session.run("CREATE ({id: $id})", Map.of("id", nodeId)))
.subscribe(new BaseSubscriber<>() {
@Override
protected void hookOnSubscribe(Subscription subscription) {
protected void hookOnSubscribe(@NonNull Subscription subscription) {
subscription.cancel();
cancellationFuture.complete(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import reactor.core.publisher.BaseSubscriber;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.util.annotation.NonNull;

@EnabledOnNeo4jWith(BOLT_V4)
@ParallelizableIT
Expand Down Expand Up @@ -97,14 +98,14 @@ void shouldReleaseResultsOnSubscriptionCancellation(boolean request) throws Inte
.run("UNWIND range (0,10000) AS x RETURN x")
.subscribe(new BaseSubscriber<>() {
@Override
protected void hookOnSubscribe(Subscription subscription) {
protected void hookOnSubscribe(@NonNull Subscription subscription) {
// use subscription from another thread to avoid immediate cancellation
// within the subscribe method
subscriptionFuture.complete(subscription);
}

@Override
protected void hookOnNext(ReactiveResult result) {
protected void hookOnNext(@NonNull ReactiveResult result) {
Mono.fromDirect(result.consume()).subscribe();
}
});
Expand Down Expand Up @@ -150,7 +151,7 @@ void shouldRollbackResultOnSubscriptionCancellation() {

session.run("CREATE ({id: $id})", Map.of("id", nodeId)).subscribe(new BaseSubscriber<>() {
@Override
protected void hookOnSubscribe(Subscription subscription) {
protected void hookOnSubscribe(@NonNull Subscription subscription) {
subscription.cancel();
cancellationFuture.complete(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ void shouldNotBeAbleToCreatePathWithEvenNumberOfEntities() {

@Test
void shouldNotBeAbleToCreatePathWithNullEntities() {
InternalNode nullNode = null;
assertThrows(IllegalArgumentException.class, () -> new InternalPath(nullNode));
assertThrows(IllegalArgumentException.class, () -> new InternalPath((InternalNode) null));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void shouldReadBackChangedEncryption() throws IOException, ClassNotFoundExceptio
var verify = TestUtil.serializeAndReadBack(securitySettings, SecuritySettings.class);

assertTrue(isCustomized(verify));
assertTrue(securitySettings.encrypted());
assertTrue(verify.encrypted());
}

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

assertTrue(isCustomized(verify));
assertFalse(securitySettings.encrypted());
assertFalse(verify.encrypted());
assertEquals(
Config.TrustStrategy.trustAllCertificates().strategy(),
securitySettings.trustStrategy().strategy());
verify.trustStrategy().strategy());
}

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

assertTrue(isCustomized(verify));
assertFalse(securitySettings.encrypted());
assertFalse(verify.encrypted());
assertEquals(
Config.TrustStrategy.trustCustomCertificateSignedBy(new File("some.cert"))
.strategy(),
securitySettings.trustStrategy().strategy());
verify.trustStrategy().strategy());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.reactivestreams.Subscription;
import reactor.core.publisher.BaseSubscriber;
import reactor.test.StepVerifier;
import reactor.util.annotation.NonNull;

class RxUtilsTest {
@Test
Expand Down Expand Up @@ -94,7 +95,7 @@ void singleItemPublisherShouldHandleCancellationAfterRequestProcessingBegins() {
// WHEN
publisher.subscribe(new BaseSubscriber<>() {
@Override
protected void hookOnSubscribe(Subscription subscription) {
protected void hookOnSubscribe(@NonNull Subscription subscription) {
subscription.request(1);
supplierInvokedFuture.thenAccept(ignored -> {
subscription.cancel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ void shouldThrowWhenNegativeLinkedHashMapSizeGiven() {
}

@Test
@SuppressWarnings("ConstantValue")
void shouldReturnEmptyQueue() {
var queue = Iterables.emptyQueue();
assertEquals(0, queue.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import reactor.core.publisher.FluxSink;
import reactor.core.publisher.Mono;
import reactor.core.publisher.MonoSink;
import reactor.util.annotation.NonNull;

/**
* Buffered subscriber for testing purposes.
Expand Down Expand Up @@ -87,12 +88,12 @@ public Mono<T> next() {
}

@Override
protected void hookOnSubscribe(Subscription subscription) {
protected void hookOnSubscribe(@NonNull Subscription subscription) {
subscriptionFuture.complete(subscription);
}

@Override
protected void hookOnNext(T value) {
protected void hookOnNext(@NonNull T value) {
executeWithLock(lock, () -> pendingItems--);
itemsSink.next(value);
}
Expand All @@ -103,7 +104,7 @@ protected void hookOnComplete() {
}

@Override
protected void hookOnError(Throwable throwable) {
protected void hookOnError(@NonNull Throwable throwable) {
itemsSink.error(throwable);
}

Expand Down Expand Up @@ -163,12 +164,12 @@ public void requestNext(MonoSink<T> sink) {
}

@Override
protected void hookOnSubscribe(Subscription subscription) {
protected void hookOnSubscribe(@NonNull Subscription subscription) {
// left empty to prevent requesting signals immediately
}

@Override
protected void hookOnNext(T value) {
protected void hookOnNext(@NonNull T value) {
var sink = executeWithLock(lock, () -> {
emitted = true;
return this.sink;
Expand All @@ -188,7 +189,7 @@ protected void hookOnComplete() {
}

@Override
protected void hookOnError(Throwable throwable) {
protected void hookOnError(@NonNull Throwable throwable) {
var sink = executeWithLock(lock, () -> {
completionFuture.completeExceptionally(throwable);
return !emitted ? this.sink : null;
Expand Down