Finally fixed connection leak in /reloadredis !!!
This commit is contained in:
parent
5699b9445f
commit
2d5d281fe4
@ -22,7 +22,7 @@ public class CommandReloadRedis implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
plugin.getRedisManager().reload();
|
plugin.getRedisManager().reload();
|
||||||
//not sending to sender, because this command can only be executed via console
|
//not sending to sender, because this command can only be executed via console
|
||||||
Bukkit.getLogger().info(ChatColor.translateAlternateColorCodes('&', "&eReloaded via command! Note this command is not stable, it should only be used in urgent cases where you absolutely need to change config details without restarting the server."));
|
Bukkit.getLogger().info(ChatColor.translateAlternateColorCodes('&', "&eReloaded channels, encryption and login details!"));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -62,8 +62,8 @@ public class RedisManager extends BinaryJedisPubSub implements Runnable {
|
|||||||
RedisService = Executors.newSingleThreadExecutor();
|
RedisService = Executors.newSingleThreadExecutor();
|
||||||
try {
|
try {
|
||||||
this.subscribeJedis = this.jedisPool.getResource();
|
this.subscribeJedis = this.jedisPool.getResource();
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {}
|
||||||
}
|
|
||||||
this.channels = config.getStringList("Channels");
|
this.channels = config.getStringList("Channels");
|
||||||
encryption = new Encryption(config);
|
encryption = new Encryption(config);
|
||||||
|
|
||||||
@ -80,8 +80,7 @@ public class RedisManager extends BinaryJedisPubSub implements Runnable {
|
|||||||
plugin.getLogger().info(ChatColor.translateAlternateColorCodes('&', "&cConnecting to redis..."));
|
plugin.getLogger().info(ChatColor.translateAlternateColorCodes('&', "&cConnecting to redis..."));
|
||||||
if (!this.subscribeJedis.isConnected()) this.subscribeJedis = this.jedisPool.getResource();
|
if (!this.subscribeJedis.isConnected()) this.subscribeJedis = this.jedisPool.getResource();
|
||||||
plugin.getLogger().info(ChatColor.translateAlternateColorCodes('&', "&aRedis connected!"));
|
plugin.getLogger().info(ChatColor.translateAlternateColorCodes('&', "&aRedis connected!"));
|
||||||
int byteArr2dSize = 1;
|
byte[][] channelsInByte = new byte[channels.size()][1];
|
||||||
byte[][] channelsInByte = new byte[channels.size()][byteArr2dSize];
|
|
||||||
for (int x = 0; x < channels.size(); x++) {
|
for (int x = 0; x < channels.size(); x++) {
|
||||||
channelsInByte[x] = channels.get(x).getBytes(StandardCharsets.UTF_8);
|
channelsInByte[x] = channels.get(x).getBytes(StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
@ -241,14 +240,17 @@ public class RedisManager extends BinaryJedisPubSub implements Runnable {
|
|||||||
if (this.subscribeJedis != null) {
|
if (this.subscribeJedis != null) {
|
||||||
this.unsubscribe();
|
this.unsubscribe();
|
||||||
this.subscribeJedis.close();
|
this.subscribeJedis.close();
|
||||||
this.subscribeJedis.getClient().close();
|
|
||||||
this.jedisPool.getResource().close();
|
|
||||||
}
|
}
|
||||||
isShuttingDown.set(true);
|
|
||||||
|
if (this.jedisPool != null) {
|
||||||
|
jedisPool.close();
|
||||||
|
jedisPool = null;
|
||||||
|
}
|
||||||
this.RedisReconnector.shutdown();
|
this.RedisReconnector.shutdown();
|
||||||
this.RedisService.shutdown();
|
this.RedisService.shutdown();
|
||||||
this.RedisService = null;
|
this.RedisService = null;
|
||||||
this.RedisReconnector = null;
|
this.RedisReconnector = null;
|
||||||
|
encryption = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
public void reload() {
|
public void reload() {
|
||||||
|
Loading…
Reference in New Issue
Block a user