Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FUSETOOLS2-1505 - avoid flakiness in case of concurrent of Diagnostics #939

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -39,7 +40,7 @@ public class DiagnosticRunner {
private ConfigurationPropertiesDiagnosticService configurationPropertiesDiagnosticService;
private CamelKModelineDiagnosticService camelKModelineDiagnosticService;
private ConnectedModeDiagnosticService connectedModeDiagnosticService;
private Map<String, CompletableFuture<Void>> lastTriggeredDiagnostic = new HashMap<String, CompletableFuture<Void>>();
private Map<String, CompletableFuture<Void>> lastTriggeredDiagnostic = new HashMap<>();

public DiagnosticRunner(CompletableFuture<CamelCatalog> camelCatalog, CamelLanguageServer camelLanguageServer) {
this.camelLanguageServer = camelLanguageServer;
Expand Down Expand Up @@ -96,7 +97,11 @@ private String retrieveFullText(DidSaveTextDocumentParams params) {
public void clear(String uri) {
CompletableFuture<Void> 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()));
}
Expand Down