diff --git a/build.gradle b/build.gradle index d38fa0f914..83aefbee6a 100644 --- a/build.gradle +++ b/build.gradle @@ -29,6 +29,12 @@ apply plugin: 'javadocHotfix' [compileJava, compileTestJava]*.options*.compilerArgs = ["-Xlint:-serial"] [compileJava, compileTestJava]*.options*.compilerArgs = ["-Xlint:-serial", "-Xlint:deprecation"] +configurations.all { + resolutionStrategy { + force 'org.apache.commons:commons-pool2:2.2' + } +} + // Common dependencies dependencies { // Logging @@ -60,7 +66,7 @@ dependencies { compile("com.fasterxml.jackson.core:jackson-databind:$fasterXmlJacksonDatabindVersion", optional) // Pool - compile("commons-pool:commons-pool:1.5.6", optional) + compile("org.apache.commons:commons-pool2:2.2", optional) // Testing testCompile "junit:junit:$junitVersion" diff --git a/gradle.properties b/gradle.properties index f09fb8eb53..38eeb1c1dd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ jredisVersion=06052013 jedisVersion=2.4.1 springVersion=3.2.8.RELEASE log4jVersion=1.2.17 -version=1.3.0.BUILD-SNAPSHOT +version=1.3.0.DATAREDIS-261-SNAPSHOT srpVersion=0.7 jacksonVersion=1.8.8 fasterXmlJacksonVersion=2.2.0 diff --git a/src/main/java/org/springframework/data/redis/connection/PoolConfig.java b/src/main/java/org/springframework/data/redis/connection/PoolConfig.java index d5f7550bb8..b377bfa8c4 100644 --- a/src/main/java/org/springframework/data/redis/connection/PoolConfig.java +++ b/src/main/java/org/springframework/data/redis/connection/PoolConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,64 +15,22 @@ */ package org.springframework.data.redis.connection; -import org.apache.commons.pool.impl.GenericObjectPool.Config; +import org.apache.commons.pool2.impl.GenericObjectPoolConfig; /** - * Subclass of {@link Config} that includes setters for instantiation in Spring + * Subclass of {@link GenericObjectPoolConfig} that includes setters for instantiation in Spring * * @author Jennifer Hickey + * @author Christoph Strobl + * @deprecated use {@link GenericObjectPoolConfig} instead. Will be removed in {@literal 1.4}. */ -public class PoolConfig extends Config { +public class PoolConfig extends GenericObjectPoolConfig { public PoolConfig() { super(); } - public void setMaxIdle(int maxIdle) { - this.maxIdle = maxIdle; - } - - public void setMinIdle(int minIdle) { - this.minIdle = minIdle; - } - public void setMaxActive(int maxActive) { - this.maxActive = maxActive; - } - - public void setMaxWait(long maxWait) { - this.maxWait = maxWait; - } - - public void setWhenExhaustedAction(byte whenExhaustedAction) { - this.whenExhaustedAction = whenExhaustedAction; - } - - public void setTestOnBorrow(boolean testOnBorrow) { - this.testOnBorrow = testOnBorrow; - } - - public void setTestOnReturn(boolean testOnReturn) { - this.testOnReturn = testOnReturn; - } - - public void setTestWhileIdle(boolean testWhileIdle) { - this.testWhileIdle = testWhileIdle; - } - - public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) { - this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis; - } - - public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun) { - this.numTestsPerEvictionRun = numTestsPerEvictionRun; - } - - public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) { - this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis; - } - - public void setSoftMinEvictableIdleTimeMillis(long softMinEvictableIdleTimeMillis) { - this.softMinEvictableIdleTimeMillis = softMinEvictableIdleTimeMillis; + setMaxTotal(maxActive); } } diff --git a/src/main/java/org/springframework/data/redis/connection/jredis/JredisPool.java b/src/main/java/org/springframework/data/redis/connection/jredis/JredisPool.java index 85be77a425..24ea13d825 100644 --- a/src/main/java/org/springframework/data/redis/connection/jredis/JredisPool.java +++ b/src/main/java/org/springframework/data/redis/connection/jredis/JredisPool.java @@ -1,5 +1,5 @@ /* - * Copyright 2011-2013 the original author or authors. + * Copyright 2011-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,9 +15,11 @@ */ package org.springframework.data.redis.connection.jredis; -import org.apache.commons.pool.BasePoolableObjectFactory; -import org.apache.commons.pool.impl.GenericObjectPool; -import org.apache.commons.pool.impl.GenericObjectPool.Config; +import org.apache.commons.pool2.BasePooledObjectFactory; +import org.apache.commons.pool2.PooledObject; +import org.apache.commons.pool2.impl.DefaultPooledObject; +import org.apache.commons.pool2.impl.GenericObjectPool; +import org.apache.commons.pool2.impl.GenericObjectPoolConfig; import org.jredis.JRedis; import org.jredis.connector.Connection; import org.jredis.connector.Connection.Socket.Property; @@ -32,10 +34,11 @@ * JRedis implementation of {@link Pool} * * @author Jennifer Hickey + * @author Christoph Strobl */ public class JredisPool implements Pool { - private final GenericObjectPool internalPool; + private final GenericObjectPool internalPool; /** * Uses the {@link Config} and {@link ConnectionSpec} defaults for configuring the connection pool @@ -44,7 +47,7 @@ public class JredisPool implements Pool { * @param port The Redis port */ public JredisPool(String hostName, int port) { - this(hostName, port, 0, null, 0, new Config()); + this(hostName, port, 0, null, 0, new GenericObjectPoolConfig()); } /** @@ -54,7 +57,7 @@ public JredisPool(String hostName, int port) { * @param port The Redis port * @param poolConfig The pool {@link Config} */ - public JredisPool(String hostName, int port, Config poolConfig) { + public JredisPool(String hostName, int port, GenericObjectPoolConfig poolConfig) { this(hostName, port, 0, null, 0, poolConfig); } @@ -64,15 +67,15 @@ public JredisPool(String hostName, int port, Config poolConfig) { * @param connectionSpec The {@link ConnectionSpec} for connecting to Redis */ public JredisPool(ConnectionSpec connectionSpec) { - this.internalPool = new GenericObjectPool(new JredisFactory(connectionSpec), new Config()); + this.internalPool = new GenericObjectPool(new JredisFactory(connectionSpec), new GenericObjectPoolConfig()); } /** * @param connectionSpec The {@link ConnectionSpec} for connecting to Redis * @param poolConfig The pool {@link Config} */ - public JredisPool(ConnectionSpec connectionSpec, Config poolConfig) { - this.internalPool = new GenericObjectPool(new JredisFactory(connectionSpec), poolConfig); + public JredisPool(ConnectionSpec connectionSpec, GenericObjectPoolConfig poolConfig) { + this.internalPool = new GenericObjectPool(new JredisFactory(connectionSpec), poolConfig); } /** @@ -87,7 +90,7 @@ public JredisPool(ConnectionSpec connectionSpec, Config poolConfig) { * @param timeout The socket timeout or 0 to use the default socket timeout */ public JredisPool(String hostName, int port, int dbIndex, String password, int timeout) { - this(hostName, port, dbIndex, password, timeout, new Config()); + this(hostName, port, dbIndex, password, timeout, new GenericObjectPoolConfig()); } /** @@ -98,7 +101,8 @@ public JredisPool(String hostName, int port, int dbIndex, String password, int t * @param timeout The socket timeout or 0 to use the default socket timeout * @param poolConfig The pool {@link Config} */ - public JredisPool(String hostName, int port, int dbIndex, String password, int timeout, Config poolConfig) { + public JredisPool(String hostName, int port, int dbIndex, String password, int timeout, + GenericObjectPoolConfig poolConfig) { ConnectionSpec connectionSpec = DefaultConnectionSpec.newSpec(hostName, port, dbIndex, null); connectionSpec.setConnectionFlag(Connection.Flag.RELIABLE, false); if (StringUtils.hasLength(password)) { @@ -107,12 +111,12 @@ public JredisPool(String hostName, int port, int dbIndex, String password, int t if (timeout > 0) { connectionSpec.setSocketProperty(Property.SO_TIMEOUT, timeout); } - this.internalPool = new GenericObjectPool(new JredisFactory(connectionSpec), poolConfig); + this.internalPool = new GenericObjectPool(new JredisFactory(connectionSpec), poolConfig); } public JRedis getResource() { try { - return (JRedis) internalPool.borrowObject(); + return internalPool.borrowObject(); } catch (Exception e) { throw new PoolException("Could not get a resource from the pool", e); } @@ -142,7 +146,7 @@ public void destroy() { } } - private static class JredisFactory extends BasePoolableObjectFactory { + private static class JredisFactory extends BasePooledObjectFactory { private final ConnectionSpec connectionSpec; @@ -151,32 +155,34 @@ public JredisFactory(ConnectionSpec connectionSpec) { this.connectionSpec = connectionSpec; } - public Object makeObject() throws Exception { - return new JRedisClient(connectionSpec); - } - - public void destroyObject(final Object obj) throws Exception { - if (obj instanceof JRedis) { - try { - ((JRedis) obj).quit(); - } catch (Exception e) { - // Errors may happen if returning a broken resource - } + @Override + public void destroyObject(final PooledObject obj) throws Exception { + try { + obj.getObject().quit(); + } catch (Exception e) { + // Errors may happen if returning a broken resource } } - public boolean validateObject(final Object obj) { - if (obj instanceof JRedis) { - try { - ((JRedis) obj).ping(); - return true; - } catch (Exception e) { - return false; - } - } else { + @Override + public boolean validateObject(final PooledObject obj) { + try { + obj.getObject().ping(); + return true; + } catch (Exception e) { return false; } } + + @Override + public JRedis create() throws Exception { + return new JRedisClient(connectionSpec); + } + + @Override + public PooledObject wrap(JRedis obj) { + return new DefaultPooledObject(obj); + } } } diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/DefaultLettucePool.java b/src/main/java/org/springframework/data/redis/connection/lettuce/DefaultLettucePool.java index cfd19079d6..178ab2fe93 100644 --- a/src/main/java/org/springframework/data/redis/connection/lettuce/DefaultLettucePool.java +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/DefaultLettucePool.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,11 @@ import java.util.concurrent.TimeUnit; -import org.apache.commons.pool.BasePoolableObjectFactory; -import org.apache.commons.pool.impl.GenericObjectPool; -import org.apache.commons.pool.impl.GenericObjectPool.Config; +import org.apache.commons.pool2.BasePooledObjectFactory; +import org.apache.commons.pool2.PooledObject; +import org.apache.commons.pool2.impl.DefaultPooledObject; +import org.apache.commons.pool2.impl.GenericObjectPool; +import org.apache.commons.pool2.impl.GenericObjectPoolConfig; import org.springframework.beans.factory.InitializingBean; import org.springframework.data.redis.connection.PoolException; import org.springframework.util.Assert; @@ -28,15 +30,18 @@ import com.lambdaworks.redis.RedisClient; /** - * Default implementation of {@link LettucePool} + * Default implementation of {@link LettucePool}. * * @author Jennifer Hickey + * @author Christoph Strobl */ public class DefaultLettucePool implements LettucePool, InitializingBean { - private GenericObjectPool internalPool; + + @SuppressWarnings("rawtypes")// + private GenericObjectPool internalPool; private RedisClient client; private int dbIndex = 0; - private Config poolConfig = new Config(); + private GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig(); private String hostName = "localhost"; private int port = 6379; private String password; @@ -63,25 +68,26 @@ public DefaultLettucePool(String hostName, int port) { * * @param hostName The Redis host * @param port The Redis port - * @param poolConfig The pool {@link Config} + * @param poolConfig The pool {@link GenericObjectPoolConfig} */ - public DefaultLettucePool(String hostName, int port, Config poolConfig) { + public DefaultLettucePool(String hostName, int port, GenericObjectPoolConfig poolConfig) { this.hostName = hostName; this.port = port; this.poolConfig = poolConfig; } + @SuppressWarnings({ "rawtypes" }) public void afterPropertiesSet() { this.client = password != null ? new AuthenticatingRedisClient(hostName, port, password) : new RedisClient( hostName, port); client.setDefaultTimeout(timeout, TimeUnit.MILLISECONDS); - this.internalPool = new GenericObjectPool(new LettuceFactory(client, dbIndex), poolConfig); + this.internalPool = new GenericObjectPool(new LettuceFactory(client, dbIndex), poolConfig); } @SuppressWarnings("unchecked") public RedisAsyncConnection getResource() { try { - return (RedisAsyncConnection) internalPool.borrowObject(); + return internalPool.borrowObject(); } catch (Exception e) { throw new PoolException("Could not get a resource from the pool", e); } @@ -119,14 +125,14 @@ public RedisClient getClient() { /** * @return The pool configuration */ - public Config getPoolConfig() { + public GenericObjectPoolConfig getPoolConfig() { return poolConfig; } /** * @param poolConfig The pool configuration to use */ - public void setPoolConfig(Config poolConfig) { + public void setPoolConfig(GenericObjectPoolConfig poolConfig) { this.poolConfig = poolConfig; } @@ -221,7 +227,8 @@ public void setTimeout(long timeout) { this.timeout = timeout; } - private static class LettuceFactory extends BasePoolableObjectFactory { + @SuppressWarnings("rawtypes") + private static class LettuceFactory extends BasePooledObjectFactory { private final RedisClient client; @@ -233,41 +240,37 @@ public LettuceFactory(RedisClient client, int dbIndex) { this.dbIndex = dbIndex; } - public Object makeObject() throws Exception { - return client.connectAsync(LettuceConnection.CODEC); - } - - @SuppressWarnings("rawtypes") @Override - public void activateObject(Object obj) throws Exception { - if (obj instanceof RedisAsyncConnection) { - ((RedisAsyncConnection) obj).select(dbIndex); - } + public void activateObject(PooledObject pooledObject) throws Exception { + pooledObject.getObject().select(dbIndex); } - @SuppressWarnings("rawtypes") - public void destroyObject(final Object obj) throws Exception { - if (obj instanceof RedisAsyncConnection) { - try { - ((RedisAsyncConnection) obj).close(); - } catch (Exception e) { - // Errors may happen if returning a broken resource - } + public void destroyObject(final PooledObject obj) throws Exception { + try { + obj.getObject().close(); + } catch (Exception e) { + // Errors may happen if returning a broken resource } } - @SuppressWarnings("rawtypes") - public boolean validateObject(final Object obj) { - if (obj instanceof RedisAsyncConnection) { - try { - ((RedisAsyncConnection) obj).ping(); - return true; - } catch (Exception e) { - return false; - } - } else { + public boolean validateObject(final PooledObject obj) { + try { + obj.getObject().ping(); + return true; + } catch (Exception e) { return false; } } + + @Override + public RedisAsyncConnection create() throws Exception { + return client.connectAsync(LettuceConnection.CODEC); + } + + @Override + public PooledObject wrap(RedisAsyncConnection obj) { + return new DefaultPooledObject(obj); + } + } } diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnection.java b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnection.java index ad1e0cac39..ce7c628f16 100644 --- a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnection.java +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnection.java @@ -314,23 +314,32 @@ public Object execute(String command, CommandOutput commandOutputTypeHint, byte[ } } + private void returnDedicatedAsyncConnection() { + + if (pool != null) { + + if (!broken) { + pool.returnResource(this.asyncDedicatedConn); + } else { + pool.returnBrokenResource(this.asyncDedicatedConn); + } + this.asyncDedicatedConn = null; + + } else { + + try { + asyncDedicatedConn.close(); + } catch (RuntimeException ex) { + throw convertLettuceAccessException(ex); + } + } + } + public void close() throws DataAccessException { isClosed = true; if (asyncDedicatedConn != null) { - if (pool != null) { - if (!broken) { - pool.returnResource(asyncDedicatedConn); - } else { - pool.returnBrokenResource(asyncDedicatedConn); - } - } else { - try { - asyncDedicatedConn.close(); - } catch (RuntimeException ex) { - throw convertLettuceAccessException(ex); - } - } + returnDedicatedAsyncConnection(); } if (subscription != null) { diff --git a/src/test/java/org/springframework/data/redis/connection/jredis/JRedisConnectionIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/jredis/JRedisConnectionIntegrationTests.java index 88806fe5dc..9725cfcda7 100644 --- a/src/test/java/org/springframework/data/redis/connection/jredis/JRedisConnectionIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/jredis/JRedisConnectionIntegrationTests.java @@ -23,7 +23,7 @@ import java.util.HashSet; import java.util.List; -import org.apache.commons.pool.impl.GenericObjectPool.Config; +import org.apache.commons.pool2.impl.GenericObjectPoolConfig; import org.hamcrest.core.IsInstanceOf; import org.jredis.JRedis; import org.jredis.protocol.BulkResponse; @@ -112,9 +112,9 @@ public void testConnectionStaysOpenWhenPooled() { @Test public void testConnectionNotReturnedOnException() { - Config config = new Config(); - config.maxActive = 1; - config.maxWait = 1; + GenericObjectPoolConfig config = new GenericObjectPoolConfig(); + config.setMaxTotal(1); + config.setMaxWaitMillis(1); JredisConnectionFactory factory2 = new JredisConnectionFactory(new JredisPool(SettingsUtils.getHost(), SettingsUtils.getPort(), config)); RedisConnection conn2 = factory2.getConnection(); diff --git a/src/test/java/org/springframework/data/redis/connection/jredis/JredisPoolTests.java b/src/test/java/org/springframework/data/redis/connection/jredis/JredisPoolTests.java index 18682d1527..6b5deec8b9 100644 --- a/src/test/java/org/springframework/data/redis/connection/jredis/JredisPoolTests.java +++ b/src/test/java/org/springframework/data/redis/connection/jredis/JredisPoolTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,9 @@ */ package org.springframework.data.redis.connection.jredis; -import org.apache.commons.pool.impl.GenericObjectPool.Config; +import static org.junit.Assert.*; + +import org.apache.commons.pool2.impl.GenericObjectPoolConfig; import org.jredis.JRedis; import org.jredis.RedisException; import org.jredis.connector.ConnectionSpec; @@ -27,13 +29,12 @@ import org.springframework.data.redis.SettingsUtils; import org.springframework.data.redis.connection.PoolException; -import static org.junit.Assert.*; - /** - * Integration test of {@link JredisPool} + * Integration test of {@link JredisPool}. * * @author Jennifer Hickey * @author Thomas Darimont + * @author Christoph Strobl */ public class JredisPoolTests { @@ -63,9 +64,9 @@ public void testGetResource() throws RedisException { @Test public void testGetResourcePoolExhausted() { - Config poolConfig = new Config(); - poolConfig.maxActive = 1; - poolConfig.maxWait = 1; + GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig(); + poolConfig.setMaxTotal(1); + poolConfig.setMaxWaitMillis(1); this.pool = new JredisPool(connectionSpec, poolConfig); JRedis client = pool.getResource(); assertNotNull(client); @@ -79,8 +80,8 @@ public void testGetResourcePoolExhausted() { @Test public void testGetResourceValidate() { - Config poolConfig = new Config(); - poolConfig.testOnBorrow = true; + GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig(); + poolConfig.setTestOnBorrow(true); this.pool = new JredisPool(connectionSpec, poolConfig); JRedis client = pool.getResource(); assertNotNull(client); @@ -96,9 +97,10 @@ public void testGetResourceCreationUnsuccessful() { @Test public void testReturnResource() throws RedisException { - Config poolConfig = new Config(); - poolConfig.maxActive = 1; - poolConfig.maxWait = 1; + + GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig(); + poolConfig.setMaxTotal(1); + poolConfig.setMaxWaitMillis(1); this.pool = new JredisPool(connectionSpec); JRedis client = pool.getResource(); assertNotNull(client); @@ -108,9 +110,10 @@ public void testReturnResource() throws RedisException { @Test public void testReturnBrokenResource() throws RedisException { - Config poolConfig = new Config(); - poolConfig.maxActive = 1; - poolConfig.maxWait = 1; + + GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig(); + poolConfig.setMaxTotal(1); + poolConfig.setMaxWaitMillis(1); this.pool = new JredisPool(connectionSpec, poolConfig); JRedis client = pool.getResource(); assertNotNull(client); diff --git a/src/test/java/org/springframework/data/redis/connection/lettuce/DefaultLettucePoolTests.java b/src/test/java/org/springframework/data/redis/connection/lettuce/DefaultLettucePoolTests.java index b084590a60..1cb710f8e1 100644 --- a/src/test/java/org/springframework/data/redis/connection/lettuce/DefaultLettucePoolTests.java +++ b/src/test/java/org/springframework/data/redis/connection/lettuce/DefaultLettucePoolTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,9 +15,9 @@ */ package org.springframework.data.redis.connection.lettuce; -import com.lambdaworks.redis.RedisAsyncConnection; -import com.lambdaworks.redis.RedisException; -import org.apache.commons.pool.impl.GenericObjectPool.Config; +import static org.junit.Assert.*; + +import org.apache.commons.pool2.impl.GenericObjectPoolConfig; import org.junit.After; import org.junit.Ignore; import org.junit.Test; @@ -25,13 +25,15 @@ import org.springframework.data.redis.connection.PoolConfig; import org.springframework.data.redis.connection.PoolException; -import static org.junit.Assert.*; +import com.lambdaworks.redis.RedisAsyncConnection; +import com.lambdaworks.redis.RedisException; /** * Unit test of {@link DefaultLettucePool} * * @author Jennifer Hickey * @author Thomas Darimont + * @author Christoph Strobl */ public class DefaultLettucePoolTests { @@ -61,9 +63,9 @@ public void testGetResource() { @Test public void testGetResourcePoolExhausted() { - Config poolConfig = new Config(); - poolConfig.maxActive = 1; - poolConfig.maxWait = 1; + GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig(); + poolConfig.setMaxTotal(1); + poolConfig.setMaxWaitMillis(1); this.pool = new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort(), poolConfig); pool.afterPropertiesSet(); RedisAsyncConnection client = pool.getResource(); @@ -96,9 +98,9 @@ public void testGetResourceCreationUnsuccessful() throws Exception { @Test public void testReturnResource() { - Config poolConfig = new Config(); - poolConfig.maxActive = 1; - poolConfig.maxWait = 1; + GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig(); + poolConfig.setMaxTotal(1); + poolConfig.setMaxWaitMillis(1); this.pool = new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort(), poolConfig); pool.afterPropertiesSet(); RedisAsyncConnection client = pool.getResource(); @@ -110,9 +112,9 @@ public void testReturnResource() { @Test public void testReturnBrokenResource() { - Config poolConfig = new Config(); - poolConfig.maxActive = 1; - poolConfig.maxWait = 1; + GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig(); + poolConfig.setMaxTotal(1); + poolConfig.setMaxWaitMillis(1); this.pool = new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort(), poolConfig); pool.afterPropertiesSet(); RedisAsyncConnection client = pool.getResource(); diff --git a/src/test/java/org/springframework/data/redis/support/collections/RedisMapTests.java b/src/test/java/org/springframework/data/redis/support/collections/RedisMapTests.java index 0ff44df7fa..aba7fed283 100644 --- a/src/test/java/org/springframework/data/redis/support/collections/RedisMapTests.java +++ b/src/test/java/org/springframework/data/redis/support/collections/RedisMapTests.java @@ -95,7 +95,7 @@ public static Collection testParams() { ObjectFactory rawFactory = new RawObjectFactory(); JedisConnectionFactory jedisConnFactory = new JedisConnectionFactory(); - jedisConnFactory.getPoolConfig().setMaxTotal(defaultPoolConfig.maxActive); + jedisConnFactory.getPoolConfig().setMaxTotal(defaultPoolConfig.getMaxTotal()); jedisConnFactory.setUsePool(true); jedisConnFactory.setPort(SettingsUtils.getPort()); jedisConnFactory.setHostName(SettingsUtils.getHost()); diff --git a/template.mf b/template.mf index 67cbf4f81e..623a15f183 100644 --- a/template.mf +++ b/template.mf @@ -21,8 +21,7 @@ Import-Template: javax.xml.transform.*;resolution:="optional";version="0", org.jredis.*;resolution:="optional";version="[1.0.0, 2.0.0)", redis.clients.*;resolution:="optional";version="[2.1.0, 2.4.1)", - org.apache.commons.pool.*;resolution:="optional";version="[1.0.0, 3.0.0)", - org.apache.commons.pool2.*;resolution:="optional";version="[1.0, 2.0)", + org.apache.commons.pool2.*;resolution:="optional";version="[1.0, 2.2)", org.codehaus.jackson.*;resolution:="optional";version="[1.6, 2.0.0)", com.fasterxml.jackson.*;resolution:="optional";version="[2.0.0, 3.0.0)", org.apache.commons.beanutils.*;resolution:="optional";version=1.8.5,