From 2c218e48efd44f836489c9c1c62d8ddba815ffb0 Mon Sep 17 00:00:00 2001 From: Ethan-Vanderheijden Date: Thu, 13 Jun 2024 19:07:47 +0800 Subject: [PATCH] Give ResponseStore for code actions a minimum history size of 8. --- .../jdt/ls/core/internal/handlers/CodeActionHandler.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/CodeActionHandler.java b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/CodeActionHandler.java index 7a03535bfb..91a0d95b13 100644 --- a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/CodeActionHandler.java +++ b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/CodeActionHandler.java @@ -77,8 +77,11 @@ import com.google.gson.JsonElement; public class CodeActionHandler { + // Store a few of the latest Code Action results because any one of them might be resolved further. + // Multiple Code Actions are computed in parallel through ForkJoinPool's common pool leading to a race condition where + // the last Code Action request to finish processing is not the client's latest request. History size must scale with pool size. public static final ResponseStore> codeActionStore - = new ResponseStore<>(ForkJoinPool.commonPool().getParallelism()); + = new ResponseStore<>(Math.max(ForkJoinPool.getCommonPoolParallelism(), 8)); public static final String COMMAND_ID_APPLY_EDIT = "java.apply.workspaceEdit"; public static CodeActionOptions createOptions(PreferenceManager preferenceManager) {