pool doesn't throw Exception anymore but JedisException
This commit is contained in:
@@ -3,6 +3,8 @@ package redis.clients.util;
|
||||
import org.apache.commons.pool.PoolableObjectFactory;
|
||||
import org.apache.commons.pool.impl.GenericObjectPool;
|
||||
|
||||
import redis.clients.jedis.JedisException;
|
||||
|
||||
public abstract class Pool<T> {
|
||||
private final GenericObjectPool internalPool;
|
||||
|
||||
@@ -12,19 +14,38 @@ public abstract class Pool<T> {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public T getResource() throws Exception {
|
||||
return (T) internalPool.borrowObject();
|
||||
public T getResource() {
|
||||
try {
|
||||
return (T) internalPool.borrowObject();
|
||||
} catch (Exception e) {
|
||||
throw new JedisException("Could not get a resource from the pool",
|
||||
e);
|
||||
}
|
||||
}
|
||||
|
||||
public void returnResource(final T resource) throws Exception {
|
||||
internalPool.returnObject(resource);
|
||||
public void returnResource(final T resource) {
|
||||
try {
|
||||
internalPool.returnObject(resource);
|
||||
} catch (Exception e) {
|
||||
throw new JedisException(
|
||||
"Could not return the resource to the pool", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void returnBrokenResource(final T resource) throws Exception {
|
||||
internalPool.invalidateObject(resource);
|
||||
public void returnBrokenResource(final T resource) {
|
||||
try {
|
||||
internalPool.invalidateObject(resource);
|
||||
} catch (Exception e) {
|
||||
throw new JedisException(
|
||||
"Could not return the resource to the pool", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void destroy() throws Exception {
|
||||
internalPool.close();
|
||||
public void destroy() {
|
||||
try {
|
||||
internalPool.close();
|
||||
} catch (Exception e) {
|
||||
throw new JedisException("Could not destroy the pool", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user