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

Use try-with-resources in checking.

This commit is contained in:
Tux 2015-05-17 14:46:44 -04:00
parent d111052ead
commit 66996a295c

View File

@ -394,9 +394,7 @@ public final class RedisBungee extends Plugin {
}
// Test the connection
Jedis rsc = null;
try {
rsc = pool.getResource();
try (Jedis rsc = pool.getResource()) {
rsc.ping();
// If that worked, now we can check for an existing, alive Bungee:
File crashFile = new File(getDataFolder(), "restarted_from_crash.txt");
@ -439,16 +437,9 @@ public final class RedisBungee extends Plugin {
getLogger().log(Level.INFO, "Successfully connected to Redis.");
} catch (JedisConnectionException e) {
if (rsc != null)
pool.returnBrokenResource(rsc);
pool.destroy();
pool = null;
rsc = null;
throw e;
} finally {
if (rsc != null && pool != null) {
pool.returnResource(rsc);
}
}
} else {
throw new RuntimeException("No redis server specified!");