2
0
mirror of https://github.com/proxiodev/RedisBungee.git synced 2024-11-23 04:28:01 +00:00

Fix Jedis connection failure detection.

This commit is contained in:
Tux 2013-12-06 21:27:28 -05:00
parent facd8de553
commit 7c35aad456

View File

@ -253,11 +253,13 @@ public class RedisBungee extends Plugin implements Listener {
if (!redisServer.equals("")) { if (!redisServer.equals("")) {
pool = new JedisPool(new JedisPoolConfig(), redisServer, redisPort, Protocol.DEFAULT_TIMEOUT, redisPassword); pool = new JedisPool(new JedisPoolConfig(), redisServer, redisPort, Protocol.DEFAULT_TIMEOUT, redisPassword);
// Test the connection // Test the connection
Jedis rsc = pool.getResource(); Jedis rsc = null;
try { try {
rsc = pool.getResource();
rsc.exists(String.valueOf(System.currentTimeMillis())); rsc.exists(String.valueOf(System.currentTimeMillis()));
getLogger().log(Level.INFO, "Successfully connected to Redis."); getLogger().log(Level.INFO, "Successfully connected to Redis.");
} catch (JedisConnectionException e) { } catch (JedisConnectionException e) {
if (rsc != null)
pool.returnBrokenResource(rsc); pool.returnBrokenResource(rsc);
getLogger().log(Level.WARNING, "Failed to connect to your Redis server! RedisBungee will still work, albeit with reduced functionality.", e); getLogger().log(Level.WARNING, "Failed to connect to your Redis server! RedisBungee will still work, albeit with reduced functionality.", e);
pool.destroy(); pool.destroy();