mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2024-11-23 04:28: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
|
// Test the connection
|
||||||
Jedis rsc = null;
|
try (Jedis rsc = pool.getResource()) {
|
||||||
try {
|
|
||||||
rsc = pool.getResource();
|
|
||||||
rsc.ping();
|
rsc.ping();
|
||||||
// If that worked, now we can check for an existing, alive Bungee:
|
// If that worked, now we can check for an existing, alive Bungee:
|
||||||
File crashFile = new File(getDataFolder(), "restarted_from_crash.txt");
|
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.");
|
getLogger().log(Level.INFO, "Successfully connected to Redis.");
|
||||||
} catch (JedisConnectionException e) {
|
} catch (JedisConnectionException e) {
|
||||||
if (rsc != null)
|
|
||||||
pool.returnBrokenResource(rsc);
|
|
||||||
pool.destroy();
|
pool.destroy();
|
||||||
pool = null;
|
pool = null;
|
||||||
rsc = null;
|
|
||||||
throw e;
|
throw e;
|
||||||
} finally {
|
|
||||||
if (rsc != null && pool != null) {
|
|
||||||
pool.returnResource(rsc);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("No redis server specified!");
|
throw new RuntimeException("No redis server specified!");
|
||||||
|
Loading…
Reference in New Issue
Block a user