Skip to content

Commit d5542be

Browse files
yu-hailonghsluoyz
andauthored
fix: fix bug that "Redis sub exception occurs and sync becomes invalid" (#30)
* Update SubThread.java fix bug #29 * Update SubThread.java Co-authored-by: Yang Luo <[email protected]>
1 parent 519931b commit d5542be

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/main/java/org/casbin/watcher/SubThread.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,18 @@ public void setUpdateCallback(Consumer<String> consumer) {
2626

2727
@Override
2828
public void run() {
29-
try (Jedis jedis = jedisPool.getResource()) {
30-
jedis.subscribe(subscriber, channel);
31-
} catch (Exception e) {
32-
e.printStackTrace();
29+
while (true) {
30+
try (Jedis jedis = jedisPool.getResource()) {
31+
jedis.subscribe(subscriber, channel);
32+
} catch (Exception e) {
33+
e.printStackTrace();
34+
} finally {
35+
try {
36+
Thread.sleep(500);
37+
} catch (InterruptedException e) {
38+
e.printStackTrace();
39+
}
40+
}
3341
}
3442
}
3543
}

0 commit comments

Comments
 (0)