mirror of
https://github.com/WiIIiam278/HuskSync.git
synced 2025-12-23 08:39:19 +00:00
refactor: use guard clause in thread unlock logic
This commit is contained in:
@@ -117,27 +117,29 @@ public class RedisManager extends JedisPubSub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onThreadUnlock(Throwable t) {
|
private void onThreadUnlock(@NotNull Throwable t) {
|
||||||
if (enabled) {
|
if (!enabled) {
|
||||||
if (reconnected) {
|
return;
|
||||||
plugin.log(Level.WARNING,
|
}
|
||||||
"Connection to the Redis server was lost. Attempting reconnection in 8 seconds...", t);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
this.unsubscribe();
|
|
||||||
} catch (Throwable ignored) {
|
|
||||||
// empty catch
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make an instant subscribe if occurs any error on initialization
|
if (reconnected) {
|
||||||
if (!reconnected) {
|
plugin.log(Level.WARNING, "Redis Server connection lost. Attempting reconnect in %ss..."
|
||||||
reconnected = true;
|
.formatted(RECONNECTION_TIME / 1000), t);
|
||||||
} else {
|
}
|
||||||
try {
|
try {
|
||||||
Thread.sleep(RECONNECTION_TIME);
|
this.unsubscribe();
|
||||||
} catch (InterruptedException e) {
|
} catch (Throwable ignored) {
|
||||||
Thread.currentThread().interrupt();
|
// empty catch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make an instant subscribe if occurs any error on initialization
|
||||||
|
if (!reconnected) {
|
||||||
|
reconnected = true;
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
Thread.sleep(RECONNECTION_TIME);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user