diff --git a/src/main/java/com/github/cameltooling/lsp/internal/diagnostic/DiagnosticRunner.java b/src/main/java/com/github/cameltooling/lsp/internal/diagnostic/DiagnosticRunner.java index f1ee537a..1831d95e 100644 --- a/src/main/java/com/github/cameltooling/lsp/internal/diagnostic/DiagnosticRunner.java +++ b/src/main/java/com/github/cameltooling/lsp/internal/diagnostic/DiagnosticRunner.java @@ -14,6 +14,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.CancellationException; import java.util.concurrent.CompletableFuture; import org.apache.camel.catalog.CamelCatalog; @@ -39,7 +40,7 @@ public class DiagnosticRunner { private ConfigurationPropertiesDiagnosticService configurationPropertiesDiagnosticService; private CamelKModelineDiagnosticService camelKModelineDiagnosticService; private ConnectedModeDiagnosticService connectedModeDiagnosticService; - private Map> lastTriggeredDiagnostic = new HashMap>(); + private Map> lastTriggeredDiagnostic = new HashMap<>(); public DiagnosticRunner(CompletableFuture camelCatalog, CamelLanguageServer camelLanguageServer) { this.camelLanguageServer = camelLanguageServer; @@ -96,7 +97,11 @@ private String retrieveFullText(DidSaveTextDocumentParams params) { public void clear(String uri) { CompletableFuture previousComputation = lastTriggeredDiagnostic.get(uri); if (previousComputation != null) { - previousComputation.cancel(true); + try { + previousComputation.cancel(true); + } catch (CancellationException ce) { + // Do nothing + } } camelLanguageServer.getClient().publishDiagnostics(new PublishDiagnosticsParams(uri, Collections.emptyList())); }