Skip to content

Commit 6cd6a84

Browse files
committed
Deprecate liveness check timeout setting
This setting is not useful after ping is removed.
1 parent db739e9 commit 6cd6a84

File tree

4 files changed

+12
-33
lines changed

4 files changed

+12
-33
lines changed

driver/src/main/java/org/neo4j/driver/internal/net/pooling/PoolSettings.java

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,38 +21,20 @@
2121

2222
public class PoolSettings
2323
{
24-
public static PoolSettings defaultSettings()
25-
{
26-
return new PoolSettings( DEFAULT_MAX_IDLE_CONNECTION_POOL_SIZE, DEFAULT_IDLE_TIME_BEFORE_CONNECTION_TEST );
27-
}
28-
2924
public static final int DEFAULT_MAX_IDLE_CONNECTION_POOL_SIZE = 10;
30-
public static final long DEFAULT_IDLE_TIME_BEFORE_CONNECTION_TEST = 200;
3125

3226
/**
3327
* Maximum number of idle connections per pool.
3428
*/
3529
private final int maxIdleConnectionPoolSize;
3630

37-
/**
38-
* Connections that have been idle longer than this threshold will have a ping test performed on them.
39-
*/
40-
private final long idleTimeBeforeConnectionTest;
41-
42-
public PoolSettings( int maxIdleConnectionPoolSize, long idleTimeBeforeConnectionTest )
31+
public PoolSettings( int maxIdleConnectionPoolSize )
4332
{
4433
this.maxIdleConnectionPoolSize = maxIdleConnectionPoolSize;
45-
this.idleTimeBeforeConnectionTest = idleTimeBeforeConnectionTest;
4634
}
4735

4836
public int maxIdleConnectionPoolSize()
4937
{
5038
return maxIdleConnectionPoolSize;
5139
}
52-
53-
public long idleTimeBeforeConnectionTest()
54-
{
55-
return idleTimeBeforeConnectionTest;
56-
}
57-
5840
}

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ public class Config
5151

5252
private final int maxIdleConnectionPoolSize;
5353

54-
/** Connections that have been idle longer than this threshold will have a ping test performed on them. */
55-
private final long idleTimeBeforeConnectionTest;
56-
5754
/** Level of encryption we need to adhere to */
5855
private final EncryptionLevel encryptionLevel;
5956

@@ -68,7 +65,6 @@ private Config( ConfigBuilder builder)
6865
this.logging = builder.logging;
6966

7067
this.maxIdleConnectionPoolSize = builder.maxIdleConnectionPoolSize;
71-
this.idleTimeBeforeConnectionTest = builder.idleTimeBeforeConnectionTest;
7268

7369
this.encryptionLevel = builder.encryptionLevel;
7470
this.trustStrategy = builder.trustStrategy;
@@ -107,11 +103,15 @@ public int maxIdleConnectionPoolSize()
107103
/**
108104
* Pooled connections that have been unused for longer than this timeout will be tested before they are
109105
* used again, to ensure they are still live.
106+
*
110107
* @return idle time in milliseconds
108+
* @deprecated pooled sessions are automatically checked for validity before being returned to the pool. This
109+
* method will always return <code>-1</code> and will be possibly removed in future.
111110
*/
111+
@Deprecated
112112
public long idleTimeBeforeConnectionTest()
113113
{
114-
return idleTimeBeforeConnectionTest;
114+
return -1;
115115
}
116116

117117
/**
@@ -159,7 +159,6 @@ public static class ConfigBuilder
159159
{
160160
private Logging logging = new JULogging( Level.INFO );
161161
private int maxIdleConnectionPoolSize = PoolSettings.DEFAULT_MAX_IDLE_CONNECTION_POOL_SIZE;
162-
private long idleTimeBeforeConnectionTest = PoolSettings.DEFAULT_IDLE_TIME_BEFORE_CONNECTION_TEST;
163162
private EncryptionLevel encryptionLevel = EncryptionLevel.REQUIRED;
164163
private TrustStrategy trustStrategy = trustAllCertificates();
165164
private int routingFailureLimit = 1;
@@ -229,10 +228,12 @@ public ConfigBuilder withMaxIdleSessions( int size )
229228
*
230229
* @param timeout minimum idle time in milliseconds
231230
* @return this builder
231+
* @deprecated pooled sessions are automatically checked for validity before being returned to the pool.
232+
* This setting will be ignored and possibly removed in future.
232233
*/
234+
@Deprecated
233235
public ConfigBuilder withSessionLivenessCheckTimeout( long timeout )
234236
{
235-
this.idleTimeBeforeConnectionTest = timeout;
236237
return this;
237238
}
238239

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,7 @@ public static Driver driver( URI uri, AuthToken authToken, Config config )
177177
}
178178

179179
// Establish pool settings
180-
PoolSettings poolSettings = new PoolSettings(
181-
config.maxIdleConnectionPoolSize(),
182-
config.idleTimeBeforeConnectionTest() );
180+
PoolSettings poolSettings = new PoolSettings( config.maxIdleConnectionPoolSize() );
183181

184182
// And finally, construct the driver proper
185183
ConnectionPool connectionPool =

driver/src/test/java/org/neo4j/driver/internal/ConfigTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@
2626
import org.neo4j.driver.v1.util.FileTools;
2727

2828
import static java.lang.System.getProperty;
29-
import static org.hamcrest.CoreMatchers.equalTo;
3029
import static org.junit.Assert.assertEquals;
31-
import static org.junit.Assert.assertThat;
3230

3331
public class ConfigTest
3432
{
@@ -79,13 +77,13 @@ public void shouldChangeToTrustedCert()
7977
}
8078

8179
@Test
82-
public void shouldConfigureMinIdleTime() throws Throwable
80+
public void shouldIgnoreLivenessCheckTimeoutSetting() throws Throwable
8381
{
8482
// when
8583
Config config = Config.build().withSessionLivenessCheckTimeout( 1337 ).toConfig();
8684

8785
// then
88-
assertThat( config.idleTimeBeforeConnectionTest(), equalTo( 1337L ) );
86+
assertEquals( -1, config.idleTimeBeforeConnectionTest() );
8987
}
9088

9189
public static void deleteDefaultKnownCertFileIfExists()

0 commit comments

Comments
 (0)