Compare commits

..

2 Commits

Author SHA1 Message Date
mohammed jasem alaajel
5f4600546e small fix to make sure the connect was killed 2020-07-30 09:35:50 +04:00
mohammed jasem alaajel
f4ab43bcb8 added protection to kill current working sub 2020-07-28 10:53:42 +04:00
2 changed files with 14 additions and 1 deletions

View File

@@ -6,7 +6,7 @@
<groupId>net.limework.core</groupId> <groupId>net.limework.core</groupId>
<artifactId>LimeworkSpigotCore</artifactId> <artifactId>LimeworkSpigotCore</artifactId>
<version>1.0.3-SNAPSHOT</version> <version>1.0.3-fix2-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<build> <build>

View File

@@ -32,6 +32,8 @@ public class RedisManager extends BinaryJedisPubSub implements Runnable, Command
private JedisPool jedisPool; private JedisPool jedisPool;
private ExecutorService RedisService; private ExecutorService RedisService;
private AtomicBoolean isKilled = new AtomicBoolean();
//sub //sub
private BinaryJedis subscribeJedis; private BinaryJedis subscribeJedis;
@@ -72,6 +74,7 @@ public class RedisManager extends BinaryJedisPubSub implements Runnable, Command
@Override @Override
public void run() { public void run() {
while (!isShuttingDown.get()) { while (!isShuttingDown.get()) {
isKilled.set(false);
try { try {
message("&e[Jedis] &cConnecting to redis..........."); message("&e[Jedis] &cConnecting to redis...........");
if (!this.subscribeJedis.isConnected()) this.subscribeJedis = this.jedisPool.getResource(); if (!this.subscribeJedis.isConnected()) this.subscribeJedis = this.jedisPool.getResource();
@@ -110,6 +113,7 @@ public class RedisManager extends BinaryJedisPubSub implements Runnable, Command
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }
if (isKilled.get()) break;
} }
} }
@@ -179,6 +183,15 @@ public class RedisManager extends BinaryJedisPubSub implements Runnable, Command
, "&c&lYou can not execute this command!!!!!!"))); , "&c&lYou can not execute this command!!!!!!")));
return true; return true;
} }
isKilled.set(true);
try {
if (this.subscribeJedis != null) {
this.unsubscribe();
this.subscribeJedis.close();
}
} catch (Exception e) {
e.printStackTrace();
}
start(); start();
return false; return false;
} }