From 3c4c53799848a14808847c29f8b938127b0394ea Mon Sep 17 00:00:00 2001 From: Ty Date: Fri, 15 Aug 2014 14:49:01 -0400 Subject: [PATCH] Fix issue where broken Jedis instances were returned as functional instances. --- .../core/portal/PortalRepository.java | 34 +++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/PortalRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/PortalRepository.java index 43f2ff35c..986ac287c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/PortalRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/PortalRepository.java @@ -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,9 +65,18 @@ public class PortalRepository serverTransfers.add(serverTransfer); } } + catch (JedisConnectionException exception) + { + exception.printStackTrace(); + _jedisPool.returnBrokenResource(jedis); + jedis = null; + } finally { - _jedisPool.returnResource(jedis); + if (jedis != null) + { + _jedisPool.returnResource(jedis); + } } return serverTransfers; @@ -91,9 +101,18 @@ public class PortalRepository transaction.set(dataKey, serializedTransfer); transaction.exec(); } + catch (JedisConnectionException exception) + { + exception.printStackTrace(); + _jedisPool.returnBrokenResource(jedis); + jedis = null; + } finally { - _jedisPool.returnResource(jedis); + if (jedis != null) + { + _jedisPool.returnResource(jedis); + } } } @@ -124,9 +143,18 @@ public class PortalRepository removedTransfer = true; } } + catch (JedisConnectionException exception) + { + exception.printStackTrace(); + _jedisPool.returnBrokenResource(jedis); + jedis = null; + } finally { - _jedisPool.returnResource(jedis); + if (jedis != null) + { + _jedisPool.returnResource(jedis); + } } return removedTransfer;