Fix Jedis conns not returning to pool on failed select
DATAREDIS-213
This commit is contained in:
@@ -205,26 +205,29 @@ public class JedisConnection implements RedisConnection {
|
||||
|
||||
public void close() throws DataAccessException {
|
||||
// return the connection to the pool
|
||||
try {
|
||||
if (pool != null) {
|
||||
if (!broken) {
|
||||
// reset the connection
|
||||
if (pool != null) {
|
||||
if (!broken) {
|
||||
// reset the connection
|
||||
try {
|
||||
if (dbIndex > 0) {
|
||||
select(0);
|
||||
}
|
||||
jedis.select(0);
|
||||
}
|
||||
pool.returnResource(jedis);
|
||||
return;
|
||||
}
|
||||
} catch(Exception ex) {
|
||||
DataAccessException dae = convertJedisAccessException(ex);
|
||||
if(broken) {
|
||||
pool.returnBrokenResource(jedis);
|
||||
} else {
|
||||
pool.returnResource(jedis);
|
||||
}
|
||||
throw dae;
|
||||
}
|
||||
} else {
|
||||
pool.returnBrokenResource(jedis);
|
||||
return;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
// exceptions are handled below
|
||||
}
|
||||
|
||||
if (pool != null && broken) {
|
||||
pool.returnBrokenResource(jedis);
|
||||
return;
|
||||
}
|
||||
|
||||
// else close the connection normally (doing the try/catch dance)
|
||||
Exception exc = null;
|
||||
if (isQueueing()) {
|
||||
|
||||
Reference in New Issue
Block a user