From 5b438eb1485fc6df13bef08bec577ffb81020379 Mon Sep 17 00:00:00 2001 From: ham1255 Date: Fri, 5 Jun 2020 13:28:26 +0400 Subject: [PATCH] Fixed loop doesn;'t exist on server shutdown --- src/main/java/net/limework/skLimework/Events/RedisSub.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/limework/skLimework/Events/RedisSub.java b/src/main/java/net/limework/skLimework/Events/RedisSub.java index 19a38f7..a99ad32 100644 --- a/src/main/java/net/limework/skLimework/Events/RedisSub.java +++ b/src/main/java/net/limework/skLimework/Events/RedisSub.java @@ -16,6 +16,7 @@ public class RedisSub extends JedisPubSub implements Runnable{ private AddonPlugin plugin; private Jedis j; private String[] channels; + private Boolean isShuttingDown = false; public RedisSub(AddonPlugin plugin, Jedis j, List channels) { this.plugin = plugin; @@ -37,7 +38,7 @@ public class RedisSub extends JedisPubSub implements Runnable{ private void newJedis() { //this.unsubscribe(); this.j.close(); - while (true){ + while (!isShuttingDown){ try { plugin.getLogger().info("reconnecting to Redis!"); this.j = plugin.getJedisPool().getResource(); @@ -48,6 +49,7 @@ public class RedisSub extends JedisPubSub implements Runnable{ try { Thread.sleep(4000);}catch (InterruptedException ignored){} } } + if (isShuttingDown) return; plugin.getJedisExecutionService().execute(this); } @@ -67,6 +69,7 @@ public class RedisSub extends JedisPubSub implements Runnable{ } public void shutdown(){ + isShuttingDown = true; this.unsubscribe(); j.close(); }