Merge branch 'Issue171' of git://github.com/ivowiblo/jedis into ivowiblo-issue171
This commit is contained in:
@@ -38,6 +38,15 @@ public class JedisPool extends Pool<Jedis> {
|
||||
super(poolConfig, new JedisFactory(host, port, timeout, password, database));
|
||||
}
|
||||
|
||||
|
||||
public void returnBrokenResource(final BinaryJedis resource) {
|
||||
returnBrokenResourceObject(resource);
|
||||
}
|
||||
|
||||
public void returnResource(final BinaryJedis resource) {
|
||||
returnResourceObject(resource);
|
||||
}
|
||||
|
||||
/**
|
||||
* PoolableObjectFactory custom impl.
|
||||
*/
|
||||
@@ -101,6 +110,5 @@ public class JedisPool extends Pool<Jedis> {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ public abstract class Pool<T> {
|
||||
"Could not get a resource from the pool", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void returnResource(final T resource) {
|
||||
|
||||
public void returnResourceObject(final Object resource) {
|
||||
try {
|
||||
internalPool.returnObject(resource);
|
||||
} catch (Exception e) {
|
||||
@@ -32,8 +32,16 @@ public abstract class Pool<T> {
|
||||
"Could not return the resource to the pool", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void returnBrokenResource(final T resource) {
|
||||
returnBrokenResourceObject(resource);
|
||||
}
|
||||
|
||||
public void returnResource(final T resource) {
|
||||
returnResourceObject(resource);
|
||||
}
|
||||
|
||||
protected void returnBrokenResourceObject(final Object resource) {
|
||||
try {
|
||||
internalPool.invalidateObject(resource);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.apache.commons.pool.impl.GenericObjectPool.Config;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import redis.clients.jedis.BinaryJedis;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
import redis.clients.jedis.JedisPoolConfig;
|
||||
@@ -113,4 +114,13 @@ public class JedisPoolTest extends Assert {
|
||||
pool1.returnResource(jedis0);
|
||||
pool1.destroy();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void returnBinary() {
|
||||
JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.host,
|
||||
hnp.port, 2000);
|
||||
BinaryJedis jedis = pool.getResource();
|
||||
pool.returnResource(jedis);
|
||||
pool.destroy();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user