From 24a93bbc4eae9a2b5427d8e4da40b035d744d670 Mon Sep 17 00:00:00 2001 From: Miles Ziemer Date: Thu, 26 Sep 2024 10:36:02 -0400 Subject: [PATCH] Fix deadlock in didChangeWorkspaceFolders Blocking on the future creating the progress token with the client means the server can't actually receive the response from the client for that request. Tests don't catch this because the mock client is called directly, rather than through the server proxy. I decided to just remove the progress token code for now so didChangeWorkspaceFolders can work at all, rather than trying to make the method work asynchronously, which is a larger lift considering it mutates the server state. That change is coming though. --- .../smithy/lsp/SmithyLanguageServer.java | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/src/main/java/software/amazon/smithy/lsp/SmithyLanguageServer.java b/src/main/java/software/amazon/smithy/lsp/SmithyLanguageServer.java index d80d4a9a..f2efd72b 100644 --- a/src/main/java/software/amazon/smithy/lsp/SmithyLanguageServer.java +++ b/src/main/java/software/amazon/smithy/lsp/SmithyLanguageServer.java @@ -33,9 +33,7 @@ import java.util.Optional; import java.util.Properties; import java.util.Set; -import java.util.UUID; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; import java.util.logging.Logger; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -84,7 +82,6 @@ import org.eclipse.lsp4j.Unregistration; import org.eclipse.lsp4j.UnregistrationParams; import org.eclipse.lsp4j.WorkDoneProgressBegin; -import org.eclipse.lsp4j.WorkDoneProgressCreateParams; import org.eclipse.lsp4j.WorkDoneProgressEnd; import org.eclipse.lsp4j.WorkspaceFolder; import org.eclipse.lsp4j.WorkspaceFoldersOptions; @@ -471,20 +468,6 @@ public void didChangeWatchedFiles(DidChangeWatchedFilesParams params) { public void didChangeWorkspaceFolders(DidChangeWorkspaceFoldersParams params) { LOGGER.finest("DidChangeWorkspaceFolders"); - Either progressToken = Either.forLeft(UUID.randomUUID().toString()); - try { - client.createProgress(new WorkDoneProgressCreateParams(progressToken)).get(); - } catch (ExecutionException | InterruptedException e) { - client.error(String.format("Unable to create work done progress token: %s", e.getMessage())); - progressToken = null; - } - - if (progressToken != null) { - WorkDoneProgressBegin begin = new WorkDoneProgressBegin(); - begin.setTitle("Updating workspace"); - client.notifyProgress(new ProgressParams(progressToken, Either.forLeft(begin))); - } - for (WorkspaceFolder folder : params.getEvent().getAdded()) { loadWorkspace(folder); } @@ -496,11 +479,6 @@ public void didChangeWorkspaceFolders(DidChangeWorkspaceFoldersParams params) { unregisterSmithyFileWatchers().thenRun(this::registerSmithyFileWatchers); unregisterWorkspaceBuildFileWatchers().thenRun(this::registerWorkspaceBuildFileWatchers); sendFileDiagnosticsForManagedDocuments(); - - if (progressToken != null) { - WorkDoneProgressEnd end = new WorkDoneProgressEnd(); - client.notifyProgress(new ProgressParams(progressToken, Either.forLeft(end))); - } } private void loadWorkspace(WorkspaceFolder workspaceFolder) {