Fix issue where broken Jedis instances were returned as functional instances.

This commit is contained in:
Ty 2014-08-15 14:49:01 -04:00
parent 0d38ac4e96
commit 3c4c537998

View File

@ -14,6 +14,7 @@ import redis.clients.jedis.JedisPoolConfig;
import redis.clients.jedis.Pipeline; import redis.clients.jedis.Pipeline;
import redis.clients.jedis.Response; import redis.clients.jedis.Response;
import redis.clients.jedis.Transaction; import redis.clients.jedis.Transaction;
import redis.clients.jedis.exceptions.JedisConnectionException;
public class PortalRepository public class PortalRepository
{ {
@ -64,9 +65,18 @@ public class PortalRepository
serverTransfers.add(serverTransfer); serverTransfers.add(serverTransfer);
} }
} }
catch (JedisConnectionException exception)
{
exception.printStackTrace();
_jedisPool.returnBrokenResource(jedis);
jedis = null;
}
finally finally
{ {
_jedisPool.returnResource(jedis); if (jedis != null)
{
_jedisPool.returnResource(jedis);
}
} }
return serverTransfers; return serverTransfers;
@ -91,9 +101,18 @@ public class PortalRepository
transaction.set(dataKey, serializedTransfer); transaction.set(dataKey, serializedTransfer);
transaction.exec(); transaction.exec();
} }
catch (JedisConnectionException exception)
{
exception.printStackTrace();
_jedisPool.returnBrokenResource(jedis);
jedis = null;
}
finally finally
{ {
_jedisPool.returnResource(jedis); if (jedis != null)
{
_jedisPool.returnResource(jedis);
}
} }
} }
@ -124,9 +143,18 @@ public class PortalRepository
removedTransfer = true; removedTransfer = true;
} }
} }
catch (JedisConnectionException exception)
{
exception.printStackTrace();
_jedisPool.returnBrokenResource(jedis);
jedis = null;
}
finally finally
{ {
_jedisPool.returnResource(jedis); if (jedis != null)
{
_jedisPool.returnResource(jedis);
}
} }
return removedTransfer; return removedTransfer;