Skip to content

Commit

Permalink
Fix a potential deadlock in SearchEngine
Browse files Browse the repository at this point in the history
Signed-off-by: Snjezana Peco <snjezana.peco@redhat.com>
  • Loading branch information
snjeza authored and rgrunber committed Jan 28, 2025
1 parent cc0946b commit fffdb70
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,16 @@ public static void startBundle(String symbolicName) {
try {
long start = System.currentTimeMillis();
JavaLanguageServerPlugin.debugTrace("Starting " + symbolicName);
Platform.getBundle(symbolicName).start(Bundle.START_TRANSIENT);
Bundle bundle = Platform.getBundle(symbolicName);
if (bundle == null) {
if (!Platform.isRunning()) {
JavaLanguageServerPlugin.logInfo("The platform is not running.");
} else {
JavaLanguageServerPlugin.logInfo("There is no bundle " + symbolicName + ".");
}
return;
}
bundle.start(Bundle.START_TRANSIENT);
JavaLanguageServerPlugin.logInfo("Started " + symbolicName + " " + (System.currentTimeMillis() - start) + "ms");
} catch (BundleException e) {
logException(e.getMessage(), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.WorkingCopyOwner;
import org.eclipse.jdt.internal.core.JavaModelManager;
import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer;
import org.eclipse.jdt.ls.core.internal.BuildWorkspaceStatus;
Expand Down Expand Up @@ -606,6 +607,10 @@ public CompletableFuture<Object> executeCommand(ExecuteCommandParams params) {
Object result = commandHandler.executeCommand(params, new NullProgressMonitor());
return CompletableFuture.completedFuture(result);
} else {
// see https://github.com/redhat-developer/vscode-java/issues/3926
if (JavaModelManager.getIndexManager() != null) {
JavaModelManager.getIndexManager().waitForIndex(true, null);
}
return computeAsync((monitor) -> {
return commandHandler.executeCommand(params, monitor);
});
Expand Down

0 comments on commit fffdb70

Please sign in to comment.