redhat-developer / redhat-developer/vscode-java
When having VS Code open on a project that has a generated code srcDir, and running gradle commands from the command-line in that same folder, lock contention issues cause corrupted artifacts
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 2.3k
- Forks
- 546
- Ø Merge
- 20 Std. 1 Min.
- Gemergte PRs (30 T.)
- 11
Beschreibung
Expected Behavior
I'm using VS Code 1.17.2 + vscode-java 0.12.0, gradle 4.2.1 to build a Java 8 SpringBoot application om macOS 10.12.6. The build uses an xjc ant task to generate .java files from a few .xsd documents in the resources directory. I've verified that in my case, 11 ObjectFactory.java files are generated, and consequently, 11 ObjectFactory.class files are compiled correctly. I would expect all of those class files to end up in my resulting .war artifact.
Current Behavior
A random number of ObjectFactory.class files end up in the .war file. To verify this, see how to reproduce below.
Context
The issue occurs when vscode is open on a project which contains a generated code folder, specified as a srcDir entry in the build.gradle, and a terminal on the same project is used to run gradle commands. It looks like gradle from the command-line is competing with vscode-java/eclipse-jdt-ls/buildship for locks on files.
Note that it has been observed that specifying options.fork in the compileJava {..} section also works around the problem, although I suspect that only happens due to timing (i.e, think this is a race condition/lock contention of sorts).
Steps to Reproduce
- Git clone reproducer (git clone git@github.com:rubin55/reproducer.git)
- Open reproducer as folder in vscode
- Let vscode initialize, open a few Java files to see that class lookup works
- In particular, open a .java file from the generated source folder
- Open a terminal and cd to the reproducer
- Run this, a few times in a row:
gradle clean build && echo I found $(unzip -l build/libs/*.war | grep ObjectFactory.class | wc -l) ObjectFactory objects in archive while $(find build/classes/ -type f -name ObjectFactory.class | wc -l) were compiled and $(find build/generated/ -type f -name ObjectFactory.java | wc -l) java files where generated
Example output:
I found 1 ObjectFactory objects in archive while 11 were compiled and 11 java files where generated
- If the issue manifests, you will see that the resultant .war file will have missing ObjectFactory.class files (see message above).
- Observe vscode-java .log file and see backtraces that coincide with this issue. See attached vscode-java.log.
Your Environment
VS Code 1.17.2
VS Code Java 0.12.0
Gradle 4.2.1
Java 8 r144
macOS 10.12.6
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit dem Reproduktions-Repository, seiner build.gradle und dem im Bericht beschriebenen generierten Quellverzeichnis. Führe den wiederholten Befehl gradle clean build aus, während VS Code und vscode-java geöffnet sind, und vergleiche die generierten Java-Dateien, kompilierten Klassen und WAR-Inhalte; untersuche das angehängte vscode-java.log auf die entsprechenden Backtraces. Erledigt ist die Aufgabe, wenn der reproduzierte Build konsistent alle generierten ObjectFactory.class-Dateien enthält.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- java, vscode
- Bereich
- build-system, developer-experience, tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100