dispose only when server got fully initialized, otherwise the shutdown hangs forever
This commit is contained in:
@@ -79,24 +79,17 @@ public class JavaProjectsServiceWithFallback implements JavaProjectsService {
|
||||
|
||||
this.mainServiceInitialized = this.server
|
||||
.onInitialized(main.initialize())
|
||||
.doOnSuccess((disposable) -> {
|
||||
server.onShutdown(() -> {
|
||||
disposable.dispose();
|
||||
});
|
||||
})
|
||||
.doOnError(error -> {
|
||||
log.warn("JDT-based JavaProject service not available, will use fallback service", error);
|
||||
})
|
||||
.toFuture();
|
||||
|
||||
this.server.onShutdown(() -> {
|
||||
try {
|
||||
if (!mainServiceInitialized.isCompletedExceptionally()) {
|
||||
// If classpath listener has been added successfully, remove it
|
||||
mainServiceInitialized.thenAccept(Disposable::dispose).join();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// If completable future hasn't completed yet it might complete with exception to add classpath listener.
|
||||
// Handle exception gracefully rather than failing LS process to terminate
|
||||
log.error("", e);
|
||||
}
|
||||
}
|
||||
);
|
||||
log.info("set fallback shutdown handler");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user