You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2018/05/18 11:40:50 UTC
[directory-server] branch master updated: Fixed ApacheDS to use
commons-pool 2.5
This is an automated email from the ASF dual-hosted git repository.
elecharny pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/directory-server.git
The following commit(s) were added to refs/heads/master by this push:
new 57213b2 Fixed ApacheDS to use commons-pool 2.5
57213b2 is described below
commit 57213b23f06c99a8dc476f017e2f9cd2e92798ad
Author: Emmanuel Lécharny <el...@symas.com>
AuthorDate: Fri May 18 13:40:47 2018 +0200
Fixed ApacheDS to use commons-pool 2.5
---
apache-felix/pom.xml | 6 +--
.../template/LdapConnectionTemplateTest.java | 31 ++++++-------
.../shared/client/api/LdapConnectionPoolTest.java | 12 ++---
.../api/LightweightLdapConnectionPoolTest.java | 28 ++++++------
pom.xml | 6 +--
.../annotations/CreateLdapConnectionPool.java | 4 +-
.../core/integ/CreateLdapConnectionPoolRule.java | 52 +++++++++++-----------
7 files changed, 70 insertions(+), 69 deletions(-)
diff --git a/apache-felix/pom.xml b/apache-felix/pom.xml
index a783923..60fd75a 100644
--- a/apache-felix/pom.xml
+++ b/apache-felix/pom.xml
@@ -107,9 +107,9 @@
<version>3.2.1</version>
</artifactItem>
<artifactItem>
- <groupId>commons-pool</groupId>
- <artifactId>commons-pool</artifactId>
- <version>1.5.6</version>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-pool2</artifactId>
+ <version>2.5.0</version>
</artifactItem>
<artifactItem>
<groupId>org.mortbay.jetty</groupId>
diff --git a/ldap-client-test/src/test/java/org/apache/directory/ldap/client/template/LdapConnectionTemplateTest.java b/ldap-client-test/src/test/java/org/apache/directory/ldap/client/template/LdapConnectionTemplateTest.java
index 7f5cabf..4dbe05b 100755
--- a/ldap-client-test/src/test/java/org/apache/directory/ldap/client/template/LdapConnectionTemplateTest.java
+++ b/ldap-client-test/src/test/java/org/apache/directory/ldap/client/template/LdapConnectionTemplateTest.java
@@ -32,7 +32,8 @@ import static org.apache.directory.ldap.client.api.search.FilterBuilder.startsWi
import java.util.List;
-import org.apache.commons.pool.impl.GenericObjectPool;
+import org.apache.commons.pool2.impl.GenericObjectPool;
+import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.apache.directory.api.ldap.model.entry.Entry;
import org.apache.directory.api.ldap.model.exception.LdapException;
import org.apache.directory.api.ldap.model.message.AddResponse;
@@ -371,20 +372,20 @@ public class LdapConnectionTemplateTest
factory.setTimeOut( 30000 );
// optional, values below are defaults
- GenericObjectPool.Config poolConfig = new GenericObjectPool.Config();
- poolConfig.lifo = true;
- poolConfig.maxActive = 8;
- poolConfig.maxIdle = 8;
- poolConfig.maxWait = -1L;
- poolConfig.minEvictableIdleTimeMillis = 1000L * 60L * 30L;
- poolConfig.minIdle = 0;
- poolConfig.numTestsPerEvictionRun = 3;
- poolConfig.softMinEvictableIdleTimeMillis = -1L;
- poolConfig.testOnBorrow = false;
- poolConfig.testOnReturn = false;
- poolConfig.testWhileIdle = false;
- poolConfig.timeBetweenEvictionRunsMillis = -1L;
- poolConfig.whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_BLOCK;
+ GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
+ poolConfig.setLifo( true );
+ poolConfig.setMaxTotal( 8 );
+ poolConfig.setMaxIdle( 8 );
+ poolConfig.setMaxWaitMillis( -1L );
+ poolConfig.setMinEvictableIdleTimeMillis( 1000L * 60L * 30L );
+ poolConfig.setMinIdle( 0 );
+ poolConfig.setNumTestsPerEvictionRun( 3 );
+ poolConfig.setSoftMinEvictableIdleTimeMillis( -1L );
+ poolConfig.setTestOnBorrow( false );
+ poolConfig.setTestOnReturn( false );
+ poolConfig.setTestWhileIdle( false );
+ poolConfig.setTimeBetweenEvictionRunsMillis( -1L );
+ poolConfig.setBlockWhenExhausted( GenericObjectPoolConfig.DEFAULT_BLOCK_WHEN_EXHAUSTED );
LdapConnectionTemplate ldapConnectionTemplate =
new LdapConnectionTemplate( new LdapConnectionPool(
diff --git a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionPoolTest.java b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionPoolTest.java
index 85d8056..a7a0e07 100644
--- a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionPoolTest.java
+++ b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionPoolTest.java
@@ -25,8 +25,8 @@ import static org.junit.Assert.assertNotNull;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-import org.apache.commons.pool.PoolableObjectFactory;
-import org.apache.commons.pool.impl.GenericObjectPool;
+import org.apache.commons.pool2.PooledObjectFactory;
+import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.api.util.Network;
import org.apache.directory.ldap.client.api.LdapConnection;
@@ -114,10 +114,10 @@ public class LdapConnectionPoolTest extends AbstractLdapTestUnit
config.setLdapPort( port );
config.setName( DEFAULT_ADMIN );
config.setCredentials( DEFAULT_PASSWORD );
- PoolableObjectFactory<LdapConnection> factory = new ValidatingPoolableLdapConnectionFactory( config );
+ PooledObjectFactory<LdapConnection> factory = new ValidatingPoolableLdapConnectionFactory( config );
pool = new LdapConnectionPool( factory );
pool.setTestOnBorrow( true );
- pool.setWhenExhaustedAction( GenericObjectPool.WHEN_EXHAUSTED_GROW );
+ pool.setBlockWhenExhausted( !GenericObjectPoolConfig.DEFAULT_BLOCK_WHEN_EXHAUSTED );
}
@@ -238,9 +238,9 @@ public class LdapConnectionPoolTest extends AbstractLdapTestUnit
config.setCredentials( DEFAULT_PASSWORD );
ValidatingPoolableLdapConnectionFactory factory = new ValidatingPoolableLdapConnectionFactory( config );
LdapConnectionPool pool = new LdapConnectionPool( factory );
- pool.setMaxActive( 1 );
+ pool.setMaxTotal( 1 );
pool.setTestOnBorrow( true );
- pool.setWhenExhaustedAction( GenericObjectPool.WHEN_EXHAUSTED_FAIL );
+ pool.setBlockWhenExhausted( GenericObjectPoolConfig.DEFAULT_BLOCK_WHEN_EXHAUSTED );
for ( int i = 0; i < 100; i++ )
{
diff --git a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LightweightLdapConnectionPoolTest.java b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LightweightLdapConnectionPoolTest.java
index 092a751..dd05d29 100644
--- a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LightweightLdapConnectionPoolTest.java
+++ b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LightweightLdapConnectionPoolTest.java
@@ -26,8 +26,8 @@ import static org.junit.Assert.assertNotNull;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-import org.apache.commons.pool.PoolableObjectFactory;
-import org.apache.commons.pool.impl.GenericObjectPool;
+import org.apache.commons.pool2.PooledObjectFactory;
+import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.apache.directory.api.ldap.model.entry.Entry;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.api.util.Network;
@@ -215,13 +215,13 @@ public class LightweightLdapConnectionPoolTest extends AbstractLdapTestUnit
config.setName( DEFAULT_ADMIN );
config.setCredentials( DEFAULT_PASSWORD );
config.setTimeout( 30000 );
- PoolableObjectFactory<LdapConnection> factory = new DefaultPoolableLdapConnectionFactory( config );
+ PooledObjectFactory<LdapConnection> factory = new DefaultPoolableLdapConnectionFactory( config );
pool = new LdapConnectionPool( factory );
pool.setTestOnBorrow( true );
- pool.setWhenExhaustedAction( GenericObjectPool.WHEN_EXHAUSTED_GROW );
+ pool.setBlockWhenExhausted( !GenericObjectPoolConfig.DEFAULT_BLOCK_WHEN_EXHAUSTED );
pool.setMaxIdle( 0 );
- System.out.println( "Max Active connections =: " + pool.getMaxActive() );
+ System.out.println( "Max Active connections =: " + pool.getMaxTotal() );
}
@@ -248,13 +248,13 @@ public class LightweightLdapConnectionPoolTest extends AbstractLdapTestUnit
config.setName( DEFAULT_ADMIN );
config.setCredentials( DEFAULT_PASSWORD );
config.setTimeout( 30000 );
- PoolableObjectFactory<LdapConnection> factory = new DefaultPoolableLdapConnectionFactory( config );
+ PooledObjectFactory<LdapConnection> factory = new DefaultPoolableLdapConnectionFactory( config );
LdapConnectionPool poolNoIdle = new LdapConnectionPool( factory );
poolNoIdle.setTestOnBorrow( true );
- poolNoIdle.setWhenExhaustedAction( GenericObjectPool.WHEN_EXHAUSTED_GROW );
+ poolNoIdle.setBlockWhenExhausted( !GenericObjectPoolConfig.DEFAULT_BLOCK_WHEN_EXHAUSTED );
poolNoIdle.setMaxIdle( 0 );
- System.out.println( "Max Active connections =: " + pool.getMaxActive() );
+ System.out.println( "Max Active connections =: " + pool.getMaxTotal() );
for ( int j = 0; j < 1; j++ )
{
@@ -299,12 +299,12 @@ public class LightweightLdapConnectionPoolTest extends AbstractLdapTestUnit
config.setName( DEFAULT_ADMIN );
config.setCredentials( DEFAULT_PASSWORD );
config.setTimeout( 30000 );
- PoolableObjectFactory<LdapConnection> factory = new DefaultPoolableLdapConnectionFactory( config );
+ PooledObjectFactory<LdapConnection> factory = new DefaultPoolableLdapConnectionFactory( config );
LdapConnectionPool poolWithIdle = new LdapConnectionPool( factory );
poolWithIdle.setTestOnBorrow( true );
- poolWithIdle.setWhenExhaustedAction( GenericObjectPool.WHEN_EXHAUSTED_GROW );
+ poolWithIdle.setBlockWhenExhausted( GenericObjectPoolConfig.DEFAULT_BLOCK_WHEN_EXHAUSTED );
- System.out.println( "Max Active connections =: " + pool.getMaxActive() );
+ System.out.println( "Max Active connections =: " + pool.getMaxTotal() );
for ( int j = 0; j < 1; j++ )
{
@@ -522,11 +522,11 @@ public class LightweightLdapConnectionPoolTest extends AbstractLdapTestUnit
config.setLdapPort( getLdapServer().getPort() );
config.setName( DEFAULT_ADMIN );
config.setCredentials( DEFAULT_PASSWORD );
- PoolableObjectFactory<LdapConnection> factory = new DefaultPoolableLdapConnectionFactory( config );
+ PooledObjectFactory<LdapConnection> factory = new DefaultPoolableLdapConnectionFactory( config );
LdapConnectionPool pool = new LdapConnectionPool( factory );
- pool.setMaxActive( 1 );
+ pool.setMaxTotal( 1 );
pool.setTestOnBorrow( true );
- pool.setWhenExhaustedAction( GenericObjectPool.WHEN_EXHAUSTED_FAIL );
+ pool.setBlockWhenExhausted( GenericObjectPoolConfig.DEFAULT_BLOCK_WHEN_EXHAUSTED );
for ( int i = 0; i < 100; i++ )
{
diff --git a/pom.xml b/pom.xml
index 6904527..a971abb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -61,7 +61,7 @@
<commons.daemon.version>1.0.15</commons.daemon.version>
<commons.lang.version>2.6</commons.lang.version>
<commons.net.version>3.6</commons.net.version>
- <commons.pool.version>1.6</commons.pool.version>
+ <commons.pool.version>2.5.0</commons.pool.version>
<dnsjava.version>2.1.8</dnsjava.version>
<ehcache.version>2.10.4</ehcache.version>
<findbugs.annotations.version>1.0.0</findbugs.annotations.version>
@@ -1055,8 +1055,8 @@
</dependency>
<dependency>
- <groupId>commons-pool</groupId>
- <artifactId>commons-pool</artifactId>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-pool2</artifactId>
<version>${commons.pool.version}</version>
</dependency>
diff --git a/server-annotations/src/main/java/org/apache/directory/server/annotations/CreateLdapConnectionPool.java b/server-annotations/src/main/java/org/apache/directory/server/annotations/CreateLdapConnectionPool.java
index fd97f70..c3d6410 100755
--- a/server-annotations/src/main/java/org/apache/directory/server/annotations/CreateLdapConnectionPool.java
+++ b/server-annotations/src/main/java/org/apache/directory/server/annotations/CreateLdapConnectionPool.java
@@ -27,7 +27,7 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import org.apache.commons.pool.PoolableObjectFactory;
+import org.apache.commons.pool2.PooledObjectFactory;
import org.apache.directory.ldap.client.api.DefaultLdapConnectionFactory;
import org.apache.directory.ldap.client.api.DefaultLdapConnectionValidator;
import org.apache.directory.ldap.client.api.DefaultPoolableLdapConnectionFactory;
@@ -64,7 +64,7 @@ public @interface CreateLdapConnectionPool
/** LdapConnection pool factory implementation class */
- Class<? extends PoolableObjectFactory<LdapConnection>> factoryClass() default
+ Class<? extends PooledObjectFactory<LdapConnection>> factoryClass() default
DefaultPoolableLdapConnectionFactory.class;
diff --git a/test-framework/src/main/java/org/apache/directory/server/core/integ/CreateLdapConnectionPoolRule.java b/test-framework/src/main/java/org/apache/directory/server/core/integ/CreateLdapConnectionPoolRule.java
index 38f1e08..ed4bbe3 100755
--- a/test-framework/src/main/java/org/apache/directory/server/core/integ/CreateLdapConnectionPoolRule.java
+++ b/test-framework/src/main/java/org/apache/directory/server/core/integ/CreateLdapConnectionPoolRule.java
@@ -22,8 +22,8 @@ package org.apache.directory.server.core.integ;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
-import org.apache.commons.pool.PoolableObjectFactory;
-import org.apache.commons.pool.impl.GenericObjectPool.Config;
+import org.apache.commons.pool2.PooledObjectFactory;
+import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.apache.directory.api.ldap.codec.api.DefaultConfigurableBinaryAttributeDetector;
import org.apache.directory.api.util.Network;
import org.apache.directory.ldap.client.api.LdapConnection;
@@ -53,7 +53,7 @@ public class CreateLdapConnectionPoolRule extends CreateLdapServerRule
private LdapConnectionPool ldapConnectionPool;
private LdapConnectionFactory ldapConnectionFactory;
private LdapConnectionTemplate ldapConnectionTemplate;
- private PoolableObjectFactory<LdapConnection> poolableLdapConnectionFactory;
+ private PooledObjectFactory<LdapConnection> poolableLdapConnectionFactory;
public CreateLdapConnectionPoolRule()
@@ -96,7 +96,7 @@ public class CreateLdapConnectionPoolRule extends CreateLdapServerRule
LdapConnectionPool oldLdapConnectionPool = ldapConnectionPool;
LdapConnectionTemplate oldLdapConnectionTemplate = ldapConnectionTemplate;
- Class<? extends PoolableObjectFactory<LdapConnection>> factoryClass =
+ Class<? extends PooledObjectFactory<LdapConnection>> factoryClass =
classCreateLdapConnectionPoolRule.createLdapConnectionPool.factoryClass();
Class<? extends LdapConnectionFactory> connectionFactoryClass =
classCreateLdapConnectionPoolRule.createLdapConnectionPool.connectionFactoryClass();
@@ -134,7 +134,7 @@ public class CreateLdapConnectionPoolRule extends CreateLdapServerRule
public void evaluate() throws Throwable
{
LOG.trace( "Creating ldap connection pool" );
- Class<? extends PoolableObjectFactory<LdapConnection>> factoryClass =
+ Class<? extends PooledObjectFactory<LdapConnection>> factoryClass =
createLdapConnectionPool.factoryClass();
Class<? extends LdapConnectionFactory> connectionFactoryClass =
createLdapConnectionPool.connectionFactoryClass();
@@ -161,7 +161,7 @@ public class CreateLdapConnectionPoolRule extends CreateLdapServerRule
private LdapConnectionPool createLdapConnectionPool( LdapServer ldapServer,
- Class<? extends PoolableObjectFactory<LdapConnection>> factoryClass,
+ Class<? extends PooledObjectFactory<LdapConnection>> factoryClass,
Class<? extends LdapConnectionFactory> connectionFactoryClass,
Class<? extends LdapConnectionValidator> validatorClass )
{
@@ -183,25 +183,25 @@ public class CreateLdapConnectionPoolRule extends CreateLdapServerRule
config.setBinaryAttributeDetector( binaryAttributeDetector );
}
- Config poolConfig = new Config();
- poolConfig.lifo = createLdapConnectionPool.lifo();
- poolConfig.maxActive = createLdapConnectionPool.maxActive();
- poolConfig.maxIdle = createLdapConnectionPool.maxIdle();
- poolConfig.maxWait = createLdapConnectionPool.maxWait();
- poolConfig.minEvictableIdleTimeMillis = createLdapConnectionPool
- .minEvictableIdleTimeMillis();
- poolConfig.minIdle = createLdapConnectionPool.minIdle();
- poolConfig.numTestsPerEvictionRun = createLdapConnectionPool
- .numTestsPerEvictionRun();
- poolConfig.softMinEvictableIdleTimeMillis = createLdapConnectionPool
- .softMinEvictableIdleTimeMillis();
- poolConfig.testOnBorrow = createLdapConnectionPool.testOnBorrow();
- poolConfig.testOnReturn = createLdapConnectionPool.testOnReturn();
- poolConfig.testWhileIdle = createLdapConnectionPool.testWhileIdle();
- poolConfig.timeBetweenEvictionRunsMillis = createLdapConnectionPool
- .timeBetweenEvictionRunsMillis();
- poolConfig.whenExhaustedAction = createLdapConnectionPool
- .whenExhaustedAction();
+ GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
+ poolConfig.setLifo( createLdapConnectionPool.lifo() );
+ poolConfig.setMaxTotal( createLdapConnectionPool.maxActive() );
+ poolConfig.setMaxIdle( createLdapConnectionPool.maxIdle() );
+ poolConfig.setMaxWaitMillis( createLdapConnectionPool.maxWait() );
+ poolConfig.setMinEvictableIdleTimeMillis( createLdapConnectionPool
+ .minEvictableIdleTimeMillis() );
+ poolConfig.setMinIdle( createLdapConnectionPool.minIdle() );
+ poolConfig.setNumTestsPerEvictionRun( createLdapConnectionPool
+ .numTestsPerEvictionRun() );
+ poolConfig.setSoftMinEvictableIdleTimeMillis( createLdapConnectionPool
+ .softMinEvictableIdleTimeMillis() );
+ poolConfig.setTestOnBorrow( createLdapConnectionPool.testOnBorrow() );
+ poolConfig.setTestOnReturn( createLdapConnectionPool.testOnReturn() );
+ poolConfig.setTestWhileIdle( createLdapConnectionPool.testWhileIdle() );
+ poolConfig.setTimeBetweenEvictionRunsMillis( createLdapConnectionPool
+ .timeBetweenEvictionRunsMillis() );
+ poolConfig.setBlockWhenExhausted( createLdapConnectionPool
+ .whenExhaustedAction() == 1 );
try
{
@@ -231,7 +231,7 @@ public class CreateLdapConnectionPoolRule extends CreateLdapServerRule
try
{
- Constructor<? extends PoolableObjectFactory<LdapConnection>> constructor =
+ Constructor<? extends PooledObjectFactory<LdapConnection>> constructor =
factoryClass.getConstructor( LdapConnectionFactory.class );
poolableLdapConnectionFactory = constructor.newInstance( ldapConnectionFactory );
}
--
To stop receiving notification emails like this one, please contact
elecharny@apache.org.