Fix Jedis conns not returning to pool on failed select

DATAREDIS-213
This commit is contained in:
Jennifer Hickey
2013-07-28 21:00:08 -07:00
parent 9255ae57ad
commit 6fdab1c3c1
3 changed files with 61 additions and 15 deletions

View File

@@ -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()) {