Fixed EOFException issue with JedisPool. Was trying to reuse a broken Jedis

This commit is contained in:
Jonathan Leibiusky
2010-09-04 11:29:54 -03:00
parent 00dedc5f25
commit 68905396d5
5 changed files with 70 additions and 13 deletions

View File

@@ -41,16 +41,22 @@ public class JedisPool extends FixedResourcePool<Jedis> {
@Override
protected void destroyResource(Jedis jedis) {
jedis.quit();
try {
jedis.disconnect();
} catch (IOException e) {
throw new JedisException(e);
if (jedis.isConnected()) {
try {
jedis.quit();
jedis.disconnect();
} catch (Exception e) {
}
}
}
@Override
protected boolean isResourceValid(Jedis jedis) {
return jedis.ping().equals("PONG");
try {
return jedis.isConnected() && jedis.ping().equals("PONG");
} catch (Exception ex) {
return false;
}
}
}