Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Incremental Analysis doesn't close file correctly on Windows upon a cache hit #618

Closed
blindpirate opened this issue Sep 13, 2017 · 1 comment · Fixed by #619

Comments

@blindpirate
Copy link

commented Sep 13, 2017

Hi I'm a developer of Gradle and recently I found there might be some issue in pmd plugin. If I turn on the incremental analysis, some files wouldn't be closed correctly on Windows .

To reproduce it, you should have a windows machine. Mine is Windows 7. Here're the steps:

  • checkout blindpirate/pmd-issue branch of https://github.com/gradle/gradle
  • run ./gradlew codeQuality:integTest --tests '*WithIA*', this will run the WithIA.groovy, two simple tests with incremental analysis on. And it results in the error:
java.io.IOException: Unable to delete file: C:\tcagent1\work\6031ced305d8bea4\subprojects\code-quality\build\tmp\test files\PmdPluginIncrementalAnalysisIntegrationTest\incremental_analysi...e_enabled\p9laj\src\main\java\org\gradle\GoodClass.java

Looks like some files are not closed correctly, so the cleanup failed. As a comparison, you can run ./gradlew codeQuality:integTest --tests '*WithoutIA*', this will run the WithoutIA.groovy and everything works well, the only difference is that this test turn off the incremental analysis.

I'm not familiar with pmd, so I'm here for help, is there any possibility of not closing file correctly?

@jsotuyod Could you help me?

image

@jsotuyod

This comment has been minimized.

Copy link
Member

commented Sep 13, 2017

@blindpirate nice catch!

Definitely our bug, here is the culprit https://github.com/pmd/pmd/blob/master/pmd-core/src/main/java/net/sourceforge/pmd/SourceCodeProcessor.java#L92-L105

I'll patch it soon, so you may try with the 6.0.0-SNAPSHOT

@jsotuyod jsotuyod added the a:bug label Sep 13, 2017
@jsotuyod jsotuyod added this to the 6.0.0 milestone Sep 13, 2017
@jsotuyod jsotuyod self-assigned this Sep 13, 2017
@jsotuyod jsotuyod changed the title Incremental Analysis doesn't close file correctly on Windows [core] Incremental Analysis doesn't close file correctly on Windows Sep 13, 2017
@jsotuyod jsotuyod changed the title [core] Incremental Analysis doesn't close file correctly on Windows [core] Incremental Analysis doesn't close file correctly on Windows upon a cache hit Sep 13, 2017
jsotuyod added a commit to Monits/pmd that referenced this issue Sep 13, 2017
 - File encoding is converted to Charset only once. Errors in it's setup
wil fail the run immeditable instead of producing one error per file.
 - We make sure to close the source stream from the same place we create
it, by using try-with-resources
 - When wrapping the stream to a reader, we use try-with-resources
again, just in case
 - The bechmark code now takes into account charset setup, and more
closely resembles the normal execution path
 - This fixes pmd#618
@jsotuyod jsotuyod added the has:pr label Sep 14, 2017
adangel added a commit to adangel/pmd that referenced this issue Sep 30, 2017
@adangel adangel closed this in #619 Sep 30, 2017
blindpirate added a commit to gradle/gradle that referenced this issue Oct 9, 2017
…age for pmd incremental analysis (#2961)"

Since there're some issues unreleased in pmd plugin:

pmd/pmd#618
pmd/pmd#608

This reverts commit:

79e74d9
4c51b74
d98129f
c543f98
60fa200
bf27585
f7a4bf8
blindpirate added a commit to gradle/gradle that referenced this issue Oct 10, 2017
…age for pmd incremental analysis (#2961)"

Since there're some issues unreleased in pmd plugin:

pmd/pmd#618
pmd/pmd#608

This reverts commit:

79e74d9
4c51b74
d98129f
c543f98
60fa200
bf27585
f7a4bf8
blindpirate added a commit to gradle/gradle that referenced this issue Oct 10, 2017
…age for pmd incremental analysis (#2961)"

Since there're some issues unreleased in pmd plugin:

pmd/pmd#618
pmd/pmd#608

This reverts commit:

79e74d9
4c51b74
d98129f
c543f98
60fa200
bf27585
f7a4bf8
blindpirate added a commit to gradle/gradle that referenced this issue Oct 10, 2017
…age for pmd incremental analysis (#2961)" (#3125)

Since there're some issues unreleased in pmd plugin:

pmd/pmd#618
pmd/pmd#608

This reverts commit:

79e74d9
4c51b74
d98129f
c543f98
60fa200
bf27585
f7a4bf8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.