Fix deadlock when resetting cursor
@@ -622,11 +622,15 @@ public class PersistentSubscription implements Subscription {
}
final CompletableFuture<Void> disconnectFuture;
+
+ // Lock the Subscription object before locking the Dispatcher object to avoid deadlocks
+ synchronized (this) {
if (dispatcher != null && dispatcher.isConsumerConnected()) {
disconnectFuture = dispatcher.disconnectAllConsumers();
} else {
disconnectFuture = CompletableFuture.completedFuture(null);
}
+ }
disconnectFuture.whenComplete((aVoid, throwable) -> {
if (throwable != null) {
