mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2024-12-23 10:38:01 +00:00
Use try-with-resources in checking.
This commit is contained in:
parent
d111052ead
commit
66996a295c
@ -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!");
|
||||
|
Loading…
Reference in New Issue
Block a user