Skip to content
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

draft #1534

Closed
wants to merge 3 commits into from
Closed

draft #1534

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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 5 additions & 1 deletion driver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<rootDir>${project.basedir}/..</rootDir>
<api.classes.directory>${basedir}/target/classes-without-jpms</api.classes.directory>
<maven.compiler.xlint.extras>,-try</maven.compiler.xlint.extras>
<surefire.jpms.args>--add-opens org.neo4j.driver/org.neo4j.driver.internal.util.messaging=ALL-UNNAMED</surefire.jpms.args>
<surefire.jpms.args>--add-opens org.neo4j.driver/org.neo4j.driver.internal.bolt.basicimpl.util.messaging=ALL-UNNAMED</surefire.jpms.args>
<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>
<blockhound.tag>blockHoundTest</blockhound.tag>
<maven.deploy.skip>false</maven.deploy.skip>
Expand Down Expand Up @@ -114,6 +114,10 @@
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<dependency>
<groupId>com.tngtech.archunit</groupId>
<artifactId>archunit-junit5</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
20 changes: 11 additions & 9 deletions driver/src/main/java/org/neo4j/driver/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import org.neo4j.driver.exceptions.UnsupportedFeatureException;
import org.neo4j.driver.internal.RoutingSettings;
import org.neo4j.driver.internal.SecuritySettings;
import org.neo4j.driver.internal.async.pool.PoolSettings;
import org.neo4j.driver.internal.cluster.RoutingSettings;
import org.neo4j.driver.internal.handlers.pulln.FetchSizeUtil;
import org.neo4j.driver.internal.retry.ExponentialBackoffRetryLogic;
import org.neo4j.driver.net.ServerAddressResolver;
import org.neo4j.driver.util.Experimental;
Expand Down Expand Up @@ -359,10 +357,10 @@ public boolean isTelemetryDisabled() {
public static final class ConfigBuilder {
private Logging logging = DEV_NULL_LOGGING;
private boolean logLeakedSessions;
private int maxConnectionPoolSize = PoolSettings.DEFAULT_MAX_CONNECTION_POOL_SIZE;
private long idleTimeBeforeConnectionTest = PoolSettings.DEFAULT_IDLE_TIME_BEFORE_CONNECTION_TEST;
private long maxConnectionLifetimeMillis = PoolSettings.DEFAULT_MAX_CONNECTION_LIFETIME;
private long connectionAcquisitionTimeoutMillis = PoolSettings.DEFAULT_CONNECTION_ACQUISITION_TIMEOUT;
private int maxConnectionPoolSize = 100;
private long idleTimeBeforeConnectionTest = -1;
private long maxConnectionLifetimeMillis = TimeUnit.HOURS.toMillis(1);
private long connectionAcquisitionTimeoutMillis = TimeUnit.SECONDS.toMillis(60);
private String userAgent = format("neo4j-java/%s", driverVersion());
private final SecuritySettings.SecuritySettingsBuilder securitySettingsBuilder =
new SecuritySettings.SecuritySettingsBuilder();
Expand All @@ -371,7 +369,7 @@ public static final class ConfigBuilder {
private long maxTransactionRetryTimeMillis = ExponentialBackoffRetryLogic.DEFAULT_MAX_RETRY_TIME_MS;
private ServerAddressResolver resolver;
private MetricsAdapter metricsAdapter = MetricsAdapter.DEV_NULL;
private long fetchSize = FetchSizeUtil.DEFAULT_FETCH_SIZE;
private long fetchSize = 1000;
private int eventLoopThreads = 0;
private NotificationConfig notificationConfig = NotificationConfig.defaultConfig();

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

Expand Down
1 change: 1 addition & 0 deletions driver/src/main/java/org/neo4j/driver/GraphDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* @since 1.0
*/
public final class GraphDatabase {

private GraphDatabase() {}

/**
Expand Down
7 changes: 5 additions & 2 deletions driver/src/main/java/org/neo4j/driver/SessionConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.neo4j.driver;

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

import java.io.Serial;
import java.io.Serializable;
Expand Down Expand Up @@ -341,7 +340,11 @@ public Builder withDatabase(String database) {
* @return this builder
*/
public Builder withFetchSize(long size) {
this.fetchSize = assertValidFetchSize(size);
if (size <= 0 && size != -1) {
throw new IllegalArgumentException(String.format(
"The record fetch size may not be 0 or negative. Illegal record fetch size: %s.", size));
}
this.fetchSize = size;
return this;
}

Expand Down
67 changes: 67 additions & 0 deletions driver/src/main/java/org/neo4j/driver/internal/BoltLogger.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright (c) "Neo4j"
* Neo4j Sweden AB [https://neo4j.com]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.driver.internal;

import java.util.ResourceBundle;
import org.neo4j.driver.Logger;

public class BoltLogger implements System.Logger {
private final Logger logger;

public BoltLogger(Logger logger) {
this.logger = logger;
}

@Override
public String getName() {
throw new RuntimeException(new UnsupportedOperationException("getName() not supported"));
}

@Override
public boolean isLoggable(Level level) {
return switch (level) {
case ALL -> logger.isTraceEnabled() && logger.isDebugEnabled();
case TRACE -> logger.isTraceEnabled();
case DEBUG -> logger.isDebugEnabled();
case INFO, WARNING, ERROR -> true;
case OFF -> false;
};
}

@Override
public void log(Level level, ResourceBundle bundle, String msg, Throwable thrown) {
switch (level) {
case ALL, OFF -> {}
case TRACE -> logger.trace(msg, thrown);
case DEBUG -> logger.debug(msg, thrown);
case INFO -> logger.info(msg, thrown);
case WARNING -> logger.warn(msg, thrown);
case ERROR -> logger.error(msg, thrown);
}
}

@Override
public void log(Level level, ResourceBundle bundle, String format, Object... params) {
switch (level) {
case TRACE -> logger.trace(format, params);
case DEBUG -> logger.debug(format, params);
case INFO -> logger.info(format, params);
case WARNING -> logger.warn(format, params);
case ALL, OFF, ERROR -> {}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) "Neo4j"
* Neo4j Sweden AB [https://neo4j.com]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.driver.internal;

import org.neo4j.driver.Logging;
import org.neo4j.driver.internal.bolt.api.LoggingProvider;

public class BoltLoggingProvider implements LoggingProvider {
private final Logging logging;

public BoltLoggingProvider(Logging logging) {
this.logging = logging;
}

@Override
public System.Logger getLog(Class<?> cls) {
return new BoltLogger(logging.getLog(cls));
}

@Override
public System.Logger getLog(String name) {
return new BoltLogger(logging.getLog(name));
}
}

This file was deleted.

Loading