Skip to content

Commit 45a3c7f

Browse files
committed
One more try to fix deadlock
Suspect that `Mono.empty().subscribeOn` is just not working properly. So just avoid using it.
1 parent 1515345 commit 45a3c7f

File tree

1 file changed

+15
-10
lines changed
  • headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/util

1 file changed

+15
-10
lines changed

headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/util/SimpleLanguageServer.java

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -625,14 +625,9 @@ public void validateWith(TextDocumentIdentifier docId, IReconcileEngine engine)
625625
}
626626
// Log.debug("Reconciling BUSY");
627627

628-
CompletableFuture<Void> currentSession = this.busyReconcile = new CompletableFuture<>();
629-
// Avoid running in the same thread as lsp4j as it can result
630-
// in long "hangs" for slow reconcile providers
631-
Mono<?> mono = props.getReconcileDelay() > 0
632-
? Mono.delay(Duration.ofMillis(props.getReconcileDelay())).publishOn(RECONCILER_SCHEDULER)
633-
: Mono.empty().subscribeOn(RECONCILER_SCHEDULER);
628+
CompletableFuture<Void> currentSession = this.busyReconcile = new CompletableFuture<>();
634629

635-
mono.then(Mono.fromRunnable(() -> {
630+
Mono<Object> doReconcile = Mono.fromRunnable(() -> {
636631
reconcileRequests.remove(uri);
637632
log.debug("Reconcile starting {}", uri);
638633

@@ -699,16 +694,26 @@ public void accept(ReconcileProblem problem) {
699694
};
700695

701696
engine.reconcile(doc, problems);
702-
}))
697+
})
703698
.onErrorResume(error -> {
704699
log.error("", error);
705700
return Mono.empty();
706701
})
707702
.doFinally(ignore -> {
708703
currentSession.complete(null);
709704
// Log.debug("Reconciler DONE : "+this.busyReconcile.isDone());
710-
})
711-
.subscribe();
705+
});
706+
707+
// Use RECONCILER_SCHEDULER to avoid running in the same thread as lsp4j as it can result
708+
// in long "hangs" for slow reconcile providers
709+
if (props.getReconcileDelay() > 0) {
710+
Mono.delay(Duration.ofMillis(props.getReconcileDelay()))
711+
.publishOn(RECONCILER_SCHEDULER)
712+
.then(doReconcile)
713+
.subscribe();
714+
} else {
715+
doReconcile.subscribeOn(RECONCILER_SCHEDULER).subscribe();
716+
}
712717
}
713718

714719
public DiagnosticSeverity getDiagnosticSeverity(ReconcileProblem problem) {

0 commit comments

Comments
 (0)