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.Response;
import redis.clients.jedis.Transaction;
import redis.clients.jedis.exceptions.JedisConnectionException;
public class PortalRepository
{
@ -64,10 +65,19 @@ public class PortalRepository
serverTransfers.add(serverTransfer);
}
}
catch (JedisConnectionException exception)
{
exception.printStackTrace();
_jedisPool.returnBrokenResource(jedis);
jedis = null;
}
finally
{
if (jedis != null)
{
_jedisPool.returnResource(jedis);
}
}
return serverTransfers;
}
@ -91,11 +101,20 @@ public class PortalRepository
transaction.set(dataKey, serializedTransfer);
transaction.exec();
}
catch (JedisConnectionException exception)
{
exception.printStackTrace();
_jedisPool.returnBrokenResource(jedis);
jedis = null;
}
finally
{
if (jedis != null)
{
_jedisPool.returnResource(jedis);
}
}
}
/**
* Remove an existing {@link ServerTransfer} from this repository whose
@ -124,10 +143,19 @@ public class PortalRepository
removedTransfer = true;
}
}
catch (JedisConnectionException exception)
{
exception.printStackTrace();
_jedisPool.returnBrokenResource(jedis);
jedis = null;
}
finally
{
if (jedis != null)
{
_jedisPool.returnResource(jedis);
}
}
return removedTransfer;
}