mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2024-11-22 20:28:00 +00:00
Fix Jedis connection failure detection.
This commit is contained in:
parent
facd8de553
commit
7c35aad456
@ -253,12 +253,14 @@ 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) {
|
||||||
pool.returnBrokenResource(rsc);
|
if (rsc != null)
|
||||||
|
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();
|
||||||
pool = null;
|
pool = null;
|
||||||
|
Loading…
Reference in New Issue
Block a user