redhat-developer / redhat-developer/vscode-java

ConcurrentModificationException when importing large multi-project Gradle build (BSP/Java Build Server)

Offen
#4,043 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Gradle
Vorherrschende Sprache
TypeScript
Sterne
2.3k
Forks
546
Ø Merge
20 Std. 1 Min.
Gemergte PRs (30 T.)
11

Beschreibung

Describe the bug
When trying to import a large, multi-project Gradle build in VS Code with the latest Java and Gradle extensions, the import fails with a ConcurrentModificationException deep in the Java Build Server (BSP) integration. The error occurs even after updating to the latest extension versions, and after applying all recommended workarounds (including disabling the build server).

To Reproduce
Steps to reproduce the behavior:

  1. Open VS Code with the latest Java and Gradle extensions.
  2. Open the root folder of a large, multi-module Gradle project (with many subprojects and plugins).
  3. Wait for the Java project import to start.
  4. Observe the error in the Java/Gradle output panel.

[Error - 1:26:18 PM] 13 May 2025, 13:26:18 Initialization failed org.eclipse.lsp4j.jsonrpc.ResponseErrorException: java.lang.IllegalStateException: org.gradle.tooling.BuildActionFailureException: The supplied build action failed with an exception. java.util.concurrent.CompletionException: org.eclipse.lsp4j.jsonrpc.ResponseErrorException: java.lang.IllegalStateException: org.gradle.tooling.BuildActionFailureException: The supplied build action failed with an exception. at java.base/java.util.concurrent.CompletableFuture.reportJoin(Unknown Source) at java.base/java.util.concurrent.CompletableFuture.join(Unknown Source) at com.microsoft.gradle.bs.importer.Utils.getBuildTargetsMappedByProjectPath(Utils.java:47) at com.microsoft.gradle.bs.importer.GradleBuildServerProjectImporter.importProjects(GradleBuildServerProjectImporter.java:322) at com.microsoft.gradle.bs.importer.GradleBuildServerProjectImporter.importToWorkspace(GradleBuildServerProjectImporter.java:226) at org.eclipse.jdt.ls.core.internal.managers.ProjectsManager.importProjects(ProjectsManager.java:164) at org.eclipse.jdt.ls.core.internal.managers.ProjectsManager.initializeProjects(ProjectsManager.java:126) at org.eclipse.jdt.ls.core.internal.handlers.InitHandler$1.runInWorkspace(InitHandler.java:263) at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:43) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63) Caused by: org.eclipse.lsp4j.jsonrpc.ResponseErrorException: java.lang.IllegalStateException: org.gradle.tooling.BuildActionFailureException: The supplied build action failed with an exception. at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleResponse(RemoteEndpoint.java:220) at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:204) at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:185) at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:97) at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:114) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.base/java.util.concurrent.FutureTask.run(Unknown Source) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.base/java.lang.Thread.run(Unknown Source)

** Additional Info**:
VS code version: 1.100.0 (Universal)
Gradle extension version: 3.16.4
Project Manager for Java: 0.24.1
Extension Pack for Java: 0.29.0
Java version: 17.0.8-tem
Gradle version: 7.6

My project builds and runs fine from the command line (./gradlew tasks works).
I have already refactored my build scripts to avoid mutating sourceSets, tasks, or configurations after evaluation.
I have tried disabling the build server ("java.import.gradle.buildServer.enabled": false), but the error persists.
I have also tried importing only a minimal subset of subprojects, but the error still occurs with the full project.
I found this commit which fixes a similar issue in the Gradle extension, but my error is coming from the Java Build Server integration.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit com.microsoft.gradle.bs.importer.Utils.getBuildTargetsMappedByProjectPath und GradleBuildServerProjectImporter.importProjects. Untersuche anschließend den gemeldeten Initialisierungs-Stack und reproduziere das Problem mit dem großen Gradle-Multi-Projekt-Build. Das Issue ist abgeschlossen, wenn der Import nicht mehr mit ConcurrentModificationException fehlschlägt und die relevante Java/Gradle-Ausgabe eine erfolgreiche Projektinitialisierung bestätigt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
java
Bereich
build-system, developer-experience, devtools
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.