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

オープン
#344 コメント 10 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug Gradle
主要言語
TypeScript
スター
2.3k
フォーク
546
平均マージ
20時間 1分
マージ済み PR(30日)
11

説明

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
  1. Git clone reproducer (git clone git@github.com:rubin55/reproducer.git)
  2. Open reproducer as folder in vscode
  3. Let vscode initialize, open a few Java files to see that class lookup works
  4. In particular, open a .java file from the generated source folder
  5. Open a terminal and cd to the reproducer
  6. 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
  1. If the issue manifests, you will see that the resultant .war file will have missing ObjectFactory.class files (see message above).
  2. 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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

再現用リポジトリ、その build.gradle、およびレポートに記載されている生成ソースディレクトリから始めます。VS Code と vscode-java を開いた状態で gradle clean build コマンドを繰り返し実行し、生成された Java ファイル、コンパイル済みクラス、WAR の内容を比較します。対応するバックトレースについて、添付された vscode-java.log を調べます。再現したビルドに生成されたすべての ObjectFactory.class ファイルが一貫して含まれていれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java, vscode
領域
build-system, developer-experience, tooling
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。