Skip to content

Commit

Permalink
polish
Browse files Browse the repository at this point in the history
See #2838
  • Loading branch information
michael-simons authored and mp911de committed Nov 28, 2023
1 parent 9cd1882 commit 1dc29c1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public Driver driver() {
.withConnectionAcquisitionTimeout(2, TimeUnit.SECONDS)
.withLeakedSessionsLogging()
.build();
return GraphDatabase.driver(neo4jConnectionSupport.url, neo4jConnectionSupport.authToken, config);
return GraphDatabase.driver(neo4jConnectionSupport.uri, neo4jConnectionSupport.authToken, config);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.neo4j.driver.SessionConfig;
import org.neo4j.driver.internal.DriverFactory;
import org.neo4j.driver.internal.SecuritySettings;
import org.neo4j.driver.internal.security.SecurityPlan;
import org.neo4j.driver.internal.security.SecurityPlans;
import org.springframework.core.log.LogMessage;
import org.springframework.lang.Nullable;
Expand Down Expand Up @@ -174,12 +175,14 @@ public static final class Neo4jConnectionSupport implements ExtensionContext.Sto

private final DriverFactory driverFactory;

public final String url;
public final URI uri;

public final AuthToken authToken;

public final Config config;

private final SecurityPlan securityPlan;

private volatile ServerVersion cachedServerVersion;

/**
Expand All @@ -188,11 +191,13 @@ public static final class Neo4jConnectionSupport implements ExtensionContext.Sto
private volatile Driver driverInstance;

public Neo4jConnectionSupport(String url, AuthToken authToken) {
this.url = url;
this.uri = URI.create(url);
this.authToken = authToken;
this.config = Config.builder().withLogging(Logging.slf4j())
.withMaxConnectionPoolSize(Runtime.getRuntime().availableProcessors())
.build();
var settings = new SecuritySettings(config.encrypted(), config.trustStrategy());
this.securityPlan = SecurityPlans.createSecurityPlan(settings, uri.getScheme());
this.driverFactory = new DriverFactory();
}

Expand All @@ -219,9 +224,6 @@ public Driver getDriver() {
}

private Driver createDriverInstance() {
var uri = URI.create(url);
var settings = new SecuritySettings(config.encrypted(), config.trustStrategy());
var securityPlan = SecurityPlans.createSecurityPlan(settings, uri.getScheme());
return this.driverFactory.newInstance(uri, AuthTokenManagers.basic(() -> authToken), config, securityPlan, EVENT_LOOP_GROUP, null);
}

Expand Down

0 comments on commit 1dc29c1

Please sign in to comment.