Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public CompletionStage<FullHttpResponse> handle(HttpVersion httpVersion, Workloa
case "executeQuery" -> executeQuery(workloadRequest);
case "sessionRun" -> sessionRun(workloadRequest);
case "executeRead", "executeWrite" -> execute(workloadRequest);
default -> CompletableFuture.failedStage(
new IllegalArgumentException("Unknown workload type."));
default ->
CompletableFuture.failedStage(new IllegalArgumentException("Unknown workload type."));
},
executor)
.handle((ignored, throwable) -> {
Expand All @@ -84,10 +84,11 @@ private CompletionStage<Void> executeQuery(WorkloadRequest workloadRequest) {
return CompletableFuture.failedStage(new IllegalArgumentException("Unknown routing."));
}
return switch (workloadRequest.getMode()) {
case "sequentialSessions" -> runAsStage(() -> executeQueriesSequentially(
workloadRequest.getQueries(), workloadRequest.getDatabase(), routingControl));
case "parallelSessions" -> executeQueriesConcurrently(
workloadRequest.getQueries(), workloadRequest.getDatabase(), routingControl);
case "sequentialSessions" ->
runAsStage(() -> executeQueriesSequentially(
workloadRequest.getQueries(), workloadRequest.getDatabase(), routingControl));
case "parallelSessions" ->
executeQueriesConcurrently(workloadRequest.getQueries(), workloadRequest.getDatabase(), routingControl);
default -> CompletableFuture.failedStage(new IllegalArgumentException("Unknown workload type."));
};
}
Expand Down Expand Up @@ -131,12 +132,14 @@ private CompletionStage<Void> sessionRun(WorkloadRequest workloadRequest) {
return CompletableFuture.failedStage(new IllegalArgumentException("Unknown routing."));
}
return switch (workloadRequest.getMode()) {
case "sequentialSessions" -> runAsStage(() ->
runInMultipleSessions(workloadRequest.getQueries(), workloadRequest.getDatabase(), accessMode));
case "sequentialTransactions" -> runAsStage(
() -> runInSingleSession(workloadRequest.getQueries(), workloadRequest.getDatabase(), accessMode));
case "parallelSessions" -> runInConcurrentSessions(
workloadRequest.getQueries(), workloadRequest.getDatabase(), accessMode);
case "sequentialSessions" ->
runAsStage(() ->
runInMultipleSessions(workloadRequest.getQueries(), workloadRequest.getDatabase(), accessMode));
case "sequentialTransactions" ->
runAsStage(() ->
runInSingleSession(workloadRequest.getQueries(), workloadRequest.getDatabase(), accessMode));
case "parallelSessions" ->
runInConcurrentSessions(workloadRequest.getQueries(), workloadRequest.getDatabase(), accessMode);
default -> CompletableFuture.failedStage(new IllegalArgumentException("Unknown workload type."));
};
}
Expand Down Expand Up @@ -187,14 +190,17 @@ private CompletionStage<Void> execute(WorkloadRequest workloadRequest) {
return CompletableFuture.failedStage(new IllegalArgumentException("Unknown routing."));
}
return switch (workloadRequest.getMode()) {
case "sequentialSessions" -> runAsStage(() ->
executeInMultipleSessions(runner, workloadRequest.getQueries(), workloadRequest.getDatabase()));
case "sequentialTransactions" -> runAsStage(
() -> executeSingleSession(runner, workloadRequest.getQueries(), workloadRequest.getDatabase()));
case "sequentialQueries" -> runAsStage(() ->
executeInSingleTransaction(runner, workloadRequest.getQueries(), workloadRequest.getDatabase()));
case "parallelSessions" -> executeConcurrently(
runner, workloadRequest.getQueries(), workloadRequest.getDatabase());
case "sequentialSessions" ->
runAsStage(() ->
executeInMultipleSessions(runner, workloadRequest.getQueries(), workloadRequest.getDatabase()));
case "sequentialTransactions" ->
runAsStage(() ->
executeSingleSession(runner, workloadRequest.getQueries(), workloadRequest.getDatabase()));
case "sequentialQueries" ->
runAsStage(() -> executeInSingleTransaction(
runner, workloadRequest.getQueries(), workloadRequest.getDatabase()));
case "parallelSessions" ->
executeConcurrently(runner, workloadRequest.getQueries(), workloadRequest.getDatabase());
default -> CompletableFuture.failedStage(new IllegalArgumentException("Unknown workload type."));
};
}
Expand Down
6 changes: 2 additions & 4 deletions driver/src/main/java/org/neo4j/driver/SessionConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,10 @@ public int hashCode() {

@Override
public String toString() {
return String.format(
"""
return String.format("""
SessionParameters{bookmarks=%s, defaultAccessMode=%s, database='%s', fetchSize=%d, impersonatedUser=%s, \
bookmarkManager=%s}\
""",
bookmarks, defaultAccessMode, database, fetchSize, impersonatedUser, bookmarkManager);
""", bookmarks, defaultAccessMode, database, fetchSize, impersonatedUser, bookmarkManager);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ yield new ClientException(
.map(this::mapGqlCause)
.orElse(null));
}
case WRITE -> new SessionExpiredException(
format("Server at %s no longer accepts writes", address), boltFailureException);};
case WRITE ->
new SessionExpiredException(
format("Server at %s no longer accepts writes", address), boltFailureException);
};
} else {
result = super.mapBoltFailureException(boltFailureException);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ public abstract class AbstractRecordStateResponseHandler {

protected synchronized GqlStatusObject generateGqlStatusObject(List<String> keys) {
return switch (recordState) {
case NOT_REQUESTED -> keys.isEmpty()
? InternalGqlStatusObject.OMITTED_RESULT
: InternalGqlStatusObject.NO_DATA_UNKNOWN;
case NOT_REQUESTED ->
keys.isEmpty() ? InternalGqlStatusObject.OMITTED_RESULT : InternalGqlStatusObject.NO_DATA_UNKNOWN;
case HAD_RECORD -> InternalGqlStatusObject.SUCCESS;
case REQUESTED -> {
var message = "Unexpected state: " + recordState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,14 @@ private synchronized CompletionStage<ResultSummary> consumeAsync(Observation par
GqlStatusError.DIAGNOSTIC_RECORD,
null));
}
case FAILED -> stageExposingError(METADATA_EXTRACTOR.extractSummary(
query,
boltConnection,
runSummary.resultAvailableAfter(),
Collections.emptyMap(),
legacyNotifications,
null));
case FAILED ->
stageExposingError(METADATA_EXTRACTOR.extractSummary(
query,
boltConnection,
runSummary.resultAvailableAfter(),
Collections.emptyMap(),
legacyNotifications,
null));
case SUCCEEDED -> CompletableFuture.completedStage(summary);
};
var future = new CompletableFuture<ResultSummary>();
Expand Down Expand Up @@ -486,13 +487,16 @@ public synchronized CompletionStage<Record> singleAsync() {
GqlStatusError.DIAGNOSTIC_RECORD,
null));
}
case FAILED -> stageExposingError(null).thenApply(ignored -> {
throw new NoSuchRecordException("Cannot retrieve a single record, because this result is empty.");
});
case SUCCEEDED -> records.size() == 1
? CompletableFuture.completedFuture(records.poll())
: CompletableFuture.failedStage(new NoSuchRecordException(
"Cannot retrieve a single record, because this result is empty."));
case FAILED ->
stageExposingError(null).thenApply(ignored -> {
throw new NoSuchRecordException(
"Cannot retrieve a single record, because this result is empty.");
});
case SUCCEEDED ->
records.size() == 1
? CompletableFuture.completedFuture(records.poll())
: CompletableFuture.failedStage(new NoSuchRecordException(
"Cannot retrieve a single record, because this result is empty."));
};
}
}
Expand All @@ -519,10 +523,11 @@ yield listAsync().thenCompose(list -> {
});
}
case FAILED -> listAsync().thenApply(ignored -> null);
case SUCCEEDED -> listAsync().thenApply(list -> {
list.forEach(action);
return summary;
});
case SUCCEEDED ->
listAsync().thenApply(list -> {
list.forEach(action);
return summary;
});
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,19 @@ private static SecurityPlan createSecurityPlanImpl(
var hostnameVerificationEnabled = trustStrategy.isHostnameVerificationEnabled();
var revocationCheckingStrategy = trustStrategy.revocationCheckingStrategy();
return switch (trustStrategy.strategy()) {
case TRUST_CUSTOM_CA_SIGNED_CERTIFICATES -> SecurityPlanImpl.forCustomCASignedCertificates(
trustStrategy.certFiles(),
hostnameVerificationEnabled,
revocationCheckingStrategy,
clientCertificateManager,
logging);
case TRUST_SYSTEM_CA_SIGNED_CERTIFICATES -> SecurityPlanImpl.forSystemCASignedCertificates(
hostnameVerificationEnabled, revocationCheckingStrategy, clientCertificateManager, logging);
case TRUST_ALL_CERTIFICATES -> SecurityPlanImpl.forAllCertificates(
hostnameVerificationEnabled, revocationCheckingStrategy, clientCertificateManager, logging);
case TRUST_CUSTOM_CA_SIGNED_CERTIFICATES ->
SecurityPlanImpl.forCustomCASignedCertificates(
trustStrategy.certFiles(),
hostnameVerificationEnabled,
revocationCheckingStrategy,
clientCertificateManager,
logging);
case TRUST_SYSTEM_CA_SIGNED_CERTIFICATES ->
SecurityPlanImpl.forSystemCASignedCertificates(
hostnameVerificationEnabled, revocationCheckingStrategy, clientCertificateManager, logging);
case TRUST_ALL_CERTIFICATES ->
SecurityPlanImpl.forAllCertificates(
hostnameVerificationEnabled, revocationCheckingStrategy, clientCertificateManager, logging);
};
} else {
return insecure();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,12 @@ void shouldLoadCSV() throws Throwable {
var csvFileUrl = createLocalIrisData(session);

// When
var query = neo4j.isNeo4j44OrEarlier()
? """
var query = neo4j.isNeo4j44OrEarlier() ? """
USING PERIODIC COMMIT 40
LOAD CSV WITH HEADERS FROM $csvFileUrl AS l
MATCH (c:Class {name: l.class_name})
CREATE (s:Sample {sepal_length: l.sepal_length, sepal_width: l.sepal_width, petal_length: l.petal_length, petal_width: l.petal_width})
CREATE (c)<-[:HAS_CLASS]-(s) RETURN count(*) AS c"""
: """
CREATE (c)<-[:HAS_CLASS]-(s) RETURN count(*) AS c""" : """
LOAD CSV WITH HEADERS FROM $csvFileUrl AS l
CALL {
WITH l
Expand All @@ -75,8 +73,7 @@ private String createLocalIrisData(Session session) throws IOException {

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

private static final String IRIS_DATA =
"""
private static final String IRIS_DATA = """
sepal_length,sepal_width,petal_length,petal_width,class_name
5.1,3.5,1.4,0.2,Iris-setosa
4.9,3.0,1.4,0.2,Iris-setosa
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ static Stream<Arguments> shouldMapArgs() {
return Arrays.stream(NotificationClassification.values())
.map(notificationClassification -> switch (notificationClassification) {
case HINT -> Arguments.of(notificationClassification.toString(), NotificationCategory.HINT);
case UNRECOGNIZED -> Arguments.of(
notificationClassification.toString(), NotificationCategory.UNRECOGNIZED);
case UNSUPPORTED -> Arguments.of(
notificationClassification.toString(), NotificationCategory.UNSUPPORTED);
case PERFORMANCE -> Arguments.of(
notificationClassification.toString(), NotificationCategory.PERFORMANCE);
case DEPRECATION -> Arguments.of(
notificationClassification.toString(), NotificationCategory.DEPRECATION);
case UNRECOGNIZED ->
Arguments.of(notificationClassification.toString(), NotificationCategory.UNRECOGNIZED);
case UNSUPPORTED ->
Arguments.of(notificationClassification.toString(), NotificationCategory.UNSUPPORTED);
case PERFORMANCE ->
Arguments.of(notificationClassification.toString(), NotificationCategory.PERFORMANCE);
case DEPRECATION ->
Arguments.of(notificationClassification.toString(), NotificationCategory.DEPRECATION);
case SECURITY -> Arguments.of(notificationClassification.toString(), NotificationCategory.SECURITY);
case TOPOLOGY -> Arguments.of(notificationClassification.toString(), NotificationCategory.TOPOLOGY);
case GENERIC -> Arguments.of(notificationClassification.toString(), NotificationCategory.GENERIC);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,11 @@ public boolean isNeo4j43OrEarlier() {

private boolean isNeo4jVersionOrEarlier(int minor) {
try (var session = driver.session()) {
var neo4jVersion = session.executeRead(tx -> tx.run(
"""
var neo4jVersion = session.executeRead(
tx -> tx.run("""
CALL dbms.components() YIELD name, versions
WHERE name = 'Neo4j Kernel'
RETURN versions[0] AS version""")
.single()
.get("version")
.asString());
RETURN versions[0] AS version""").single().get("version").asString());
var versions = neo4jVersion.split("\\.");
return parseInt(versions[0]) <= 4 && parseInt(versions[1]) <= minor;
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.44.0</version>
<version>3.4.0</version>
<executions>
<execution>
<goals>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,20 @@
public class AuthTokenUtil {
public static AuthToken parseAuthToken(AuthorizationToken authTokenO) {
return switch (authTokenO.getTokens().getScheme()) {
case "basic" -> AuthTokens.basic(
authTokenO.getTokens().getPrincipal(),
authTokenO.getTokens().getCredentials(),
authTokenO.getTokens().getRealm());
case "basic" ->
AuthTokens.basic(
authTokenO.getTokens().getPrincipal(),
authTokenO.getTokens().getCredentials(),
authTokenO.getTokens().getRealm());
case "bearer" -> AuthTokens.bearer(authTokenO.getTokens().getCredentials());
case "kerberos" -> AuthTokens.kerberos(authTokenO.getTokens().getCredentials());
default -> AuthTokens.custom(
authTokenO.getTokens().getPrincipal(),
authTokenO.getTokens().getCredentials(),
authTokenO.getTokens().getRealm(),
authTokenO.getTokens().getScheme(),
authTokenO.getTokens().getParameters());
default ->
AuthTokens.custom(
authTokenO.getTokens().getPrincipal(),
authTokenO.getTokens().getCredentials(),
authTokenO.getTokens().getRealm(),
authTokenO.getTokens().getScheme(),
authTokenO.getTokens().getParameters());
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ public class TestkitRequestProcessorHandler extends ChannelInboundHandlerAdapter
public TestkitRequestProcessorHandler(BackendMode backendMode, ResponseQueueHanlder responseQueueHanlder) {
switch (backendMode) {
case ASYNC -> processorImpl = TestkitRequest::processAsync;
case REACTIVE -> processorImpl =
(request, state) -> request.processReactive(state).toFuture();
case REACTIVE ->
processorImpl =
(request, state) -> request.processReactive(state).toFuture();
default -> processorImpl = TestkitRequestProcessorHandler::wrapSyncRequest;
}
testkitState = new TestkitState(this::writeAndFlush);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ public void serialize(VectorValue vectorValue, JsonGenerator gen, SerializerProv
dtype = VectorType.DOUBLE.getName();
data = toHexString(float64Vector.toArray());
}
default -> throw new IllegalArgumentException(
"Unsupported vector type: " + vector.getClass().getName());
default ->
throw new IllegalArgumentException(
"Unsupported vector type: " + vector.getClass().getName());
}

cypherObject(gen, "CypherVector", () -> {
Expand Down