Skip to content

Commit 749b965

Browse files
committed
Bolt refactoring
more tests Update
1 parent ee9746c commit 749b965

File tree

587 files changed

+27085
-41707
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

587 files changed

+27085
-41707
lines changed

driver/pom.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<rootDir>${project.basedir}/..</rootDir>
2121
<api.classes.directory>${basedir}/target/classes-without-jpms</api.classes.directory>
2222
<maven.compiler.xlint.extras>,-try</maven.compiler.xlint.extras>
23-
<surefire.jpms.args>--add-opens org.neo4j.driver/org.neo4j.driver.internal.util.messaging=ALL-UNNAMED</surefire.jpms.args>
23+
<surefire.jpms.args>--add-opens org.neo4j.driver/org.neo4j.driver.internal.bolt.basicimpl.util.messaging=ALL-UNNAMED</surefire.jpms.args>
2424
<failsafe.parallelizable.jpms.args>--add-opens org.neo4j.driver/org.neo4j.driver.internal.util=ALL-UNNAMED --add-opens org.neo4j.driver/org.neo4j.driver.internal.async=ALL-UNNAMED</failsafe.parallelizable.jpms.args>
2525
<blockhound.tag>blockHoundTest</blockhound.tag>
2626
<maven.deploy.skip>false</maven.deploy.skip>
@@ -114,6 +114,10 @@
114114
<groupId>ch.qos.logback</groupId>
115115
<artifactId>logback-classic</artifactId>
116116
</dependency>
117+
<dependency>
118+
<groupId>com.tngtech.archunit</groupId>
119+
<artifactId>archunit-junit5</artifactId>
120+
</dependency>
117121
</dependencies>
118122

119123
<build>

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@
3131
import java.util.concurrent.TimeUnit;
3232
import java.util.logging.Level;
3333
import org.neo4j.driver.exceptions.UnsupportedFeatureException;
34+
import org.neo4j.driver.internal.RoutingSettings;
3435
import org.neo4j.driver.internal.SecuritySettings;
35-
import org.neo4j.driver.internal.async.pool.PoolSettings;
36-
import org.neo4j.driver.internal.cluster.RoutingSettings;
37-
import org.neo4j.driver.internal.handlers.pulln.FetchSizeUtil;
3836
import org.neo4j.driver.internal.retry.ExponentialBackoffRetryLogic;
3937
import org.neo4j.driver.net.ServerAddressResolver;
4038
import org.neo4j.driver.util.Experimental;
@@ -359,10 +357,10 @@ public boolean isTelemetryDisabled() {
359357
public static final class ConfigBuilder {
360358
private Logging logging = DEV_NULL_LOGGING;
361359
private boolean logLeakedSessions;
362-
private int maxConnectionPoolSize = PoolSettings.DEFAULT_MAX_CONNECTION_POOL_SIZE;
363-
private long idleTimeBeforeConnectionTest = PoolSettings.DEFAULT_IDLE_TIME_BEFORE_CONNECTION_TEST;
364-
private long maxConnectionLifetimeMillis = PoolSettings.DEFAULT_MAX_CONNECTION_LIFETIME;
365-
private long connectionAcquisitionTimeoutMillis = PoolSettings.DEFAULT_CONNECTION_ACQUISITION_TIMEOUT;
360+
private int maxConnectionPoolSize = 100;
361+
private long idleTimeBeforeConnectionTest = -1;
362+
private long maxConnectionLifetimeMillis = TimeUnit.HOURS.toMillis(1);
363+
private long connectionAcquisitionTimeoutMillis = TimeUnit.SECONDS.toMillis(60);
366364
private String userAgent = format("neo4j-java/%s", driverVersion());
367365
private final SecuritySettings.SecuritySettingsBuilder securitySettingsBuilder =
368366
new SecuritySettings.SecuritySettingsBuilder();
@@ -371,7 +369,7 @@ public static final class ConfigBuilder {
371369
private long maxTransactionRetryTimeMillis = ExponentialBackoffRetryLogic.DEFAULT_MAX_RETRY_TIME_MS;
372370
private ServerAddressResolver resolver;
373371
private MetricsAdapter metricsAdapter = MetricsAdapter.DEV_NULL;
374-
private long fetchSize = FetchSizeUtil.DEFAULT_FETCH_SIZE;
372+
private long fetchSize = 1000;
375373
private int eventLoopThreads = 0;
376374
private NotificationConfig notificationConfig = NotificationConfig.defaultConfig();
377375

@@ -602,7 +600,11 @@ public ConfigBuilder withRoutingTablePurgeDelay(long delay, TimeUnit unit) {
602600
* @return this builder
603601
*/
604602
public ConfigBuilder withFetchSize(long size) {
605-
this.fetchSize = FetchSizeUtil.assertValidFetchSize(size);
603+
if (size <= 0 && size != -1) {
604+
throw new IllegalArgumentException(String.format(
605+
"The record fetch size may not be 0 or negative. Illegal record fetch size: %s.", size));
606+
}
607+
this.fetchSize = size;
606608
return this;
607609
}
608610

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
* @since 1.0
3030
*/
3131
public final class GraphDatabase {
32+
3233
private GraphDatabase() {}
3334

3435
/**

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package org.neo4j.driver;
1818

1919
import static java.util.Objects.requireNonNull;
20-
import static org.neo4j.driver.internal.handlers.pulln.FetchSizeUtil.assertValidFetchSize;
2120

2221
import java.io.Serial;
2322
import java.io.Serializable;
@@ -341,7 +340,11 @@ public Builder withDatabase(String database) {
341340
* @return this builder
342341
*/
343342
public Builder withFetchSize(long size) {
344-
this.fetchSize = assertValidFetchSize(size);
343+
if (size <= 0 && size != -1) {
344+
throw new IllegalArgumentException(String.format(
345+
"The record fetch size may not be 0 or negative. Illegal record fetch size: %s.", size));
346+
}
347+
this.fetchSize = size;
345348
return this;
346349
}
347350

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Copyright (c) "Neo4j"
3+
* Neo4j Sweden AB [https://neo4j.com]
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.neo4j.driver.internal;
18+
19+
import java.util.ResourceBundle;
20+
import org.neo4j.driver.Logger;
21+
22+
public class BoltLogger implements System.Logger {
23+
private final Logger logger;
24+
25+
public BoltLogger(Logger logger) {
26+
this.logger = logger;
27+
}
28+
29+
@Override
30+
public String getName() {
31+
throw new RuntimeException(new UnsupportedOperationException("getName() not supported"));
32+
}
33+
34+
@Override
35+
public boolean isLoggable(Level level) {
36+
return switch (level) {
37+
case ALL -> logger.isTraceEnabled() && logger.isDebugEnabled();
38+
case TRACE -> logger.isTraceEnabled();
39+
case DEBUG -> logger.isDebugEnabled();
40+
case INFO, WARNING, ERROR -> true;
41+
case OFF -> false;
42+
};
43+
}
44+
45+
@Override
46+
public void log(Level level, ResourceBundle bundle, String msg, Throwable thrown) {
47+
switch (level) {
48+
case ALL, OFF -> {}
49+
case TRACE -> logger.trace(msg, thrown);
50+
case DEBUG -> logger.debug(msg, thrown);
51+
case INFO -> logger.info(msg, thrown);
52+
case WARNING -> logger.warn(msg, thrown);
53+
case ERROR -> logger.error(msg, thrown);
54+
}
55+
}
56+
57+
@Override
58+
public void log(Level level, ResourceBundle bundle, String format, Object... params) {
59+
switch (level) {
60+
case TRACE -> logger.trace(format, params);
61+
case DEBUG -> logger.debug(format, params);
62+
case INFO -> logger.info(format, params);
63+
case WARNING -> logger.warn(format, params);
64+
case ALL, OFF, ERROR -> {}
65+
}
66+
}
67+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright (c) "Neo4j"
3+
* Neo4j Sweden AB [https://neo4j.com]
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.neo4j.driver.internal;
18+
19+
import org.neo4j.driver.Logging;
20+
import org.neo4j.driver.internal.bolt.api.LoggingProvider;
21+
22+
public class BoltLoggingProvider implements LoggingProvider {
23+
private final Logging logging;
24+
25+
public BoltLoggingProvider(Logging logging) {
26+
this.logging = logging;
27+
}
28+
29+
@Override
30+
public System.Logger getLog(Class<?> cls) {
31+
return new BoltLogger(logging.getLog(cls));
32+
}
33+
34+
@Override
35+
public System.Logger getLog(String name) {
36+
return new BoltLogger(logging.getLog(name));
37+
}
38+
}

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

Lines changed: 0 additions & 95 deletions
This file was deleted.

0 commit comments

Comments
 (0)