Finally fixed connection leak in /reloadredis !!!

This commit is contained in:
Govindas 2020-12-03 13:07:27 +02:00
parent 89200f416f
commit 4363d121a4
2 changed files with 10 additions and 8 deletions

View File

@ -22,7 +22,7 @@ public class CommandReloadRedis implements CommandExecutor {
}
plugin.getRedisManager().reload();
//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;
}

View File

@ -62,8 +62,8 @@ public class RedisManager extends BinaryJedisPubSub implements Runnable {
RedisService = Executors.newSingleThreadExecutor();
try {
this.subscribeJedis = this.jedisPool.getResource();
} catch (Exception ignored) {
}
} catch (Exception ignored) {}
this.channels = config.getStringList("Channels");
encryption = new Encryption(config);
@ -80,8 +80,7 @@ public class RedisManager extends BinaryJedisPubSub implements Runnable {
plugin.getLogger().info(ChatColor.translateAlternateColorCodes('&', "&cConnecting to redis..."));
if (!this.subscribeJedis.isConnected()) this.subscribeJedis = this.jedisPool.getResource();
plugin.getLogger().info(ChatColor.translateAlternateColorCodes('&', "&aRedis connected!"));
int byteArr2dSize = 1;
byte[][] channelsInByte = new byte[channels.size()][byteArr2dSize];
byte[][] channelsInByte = new byte[channels.size()][1];
for (int x = 0; x < channels.size(); x++) {
channelsInByte[x] = channels.get(x).getBytes(StandardCharsets.UTF_8);
}
@ -241,14 +240,17 @@ public class RedisManager extends BinaryJedisPubSub implements Runnable {
if (this.subscribeJedis != null) {
this.unsubscribe();
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.RedisService.shutdown();
this.RedisService = null;
this.RedisReconnector = null;
encryption = null;
}
public void reload() {