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] Fix IOException loading rulesets under concurrency #235

Merged
merged 1 commit into from
Feb 12, 2017

Conversation

jsotuyod
Copy link
Member

@jsotuyod jsotuyod commented Feb 2, 2017

  • Fixes [core] Zip file stream closes spuriously when loading rulesets #234
  • When a single JVM runs multiple PMD instances under different threads,
    connections to PMD jars (and streams opened to read standard rulesets)
    are shared, causing race conditions where one thread may cause the other
    to close it's streams. This in tun produces IOExceptions.
  • This happens in Gradle when enabling parallel builds. I believe it can happen
    under Maven with -T1C too, but has not been able to reproduce it.
  • I take the chance to clean up classloader closing code.

This bug was introduced in PMD 5.5.1 and 5.4.2, when we fixed the leaked file handlers.

@jsotuyod jsotuyod added the a:bug PMD crashes or fails to analyse a file. label Feb 2, 2017
@jsotuyod jsotuyod added this to the 5.4.5 milestone Feb 2, 2017
@jsotuyod jsotuyod force-pushed the issue-234 branch 3 times, most recently from 7f0bbdc to 2f8f73d Compare February 3, 2017 01:05
@jsotuyod
Copy link
Member Author

jsotuyod commented Feb 3, 2017

I've no idea why Jacoco has big issues with the changes done to PMD.java on this commit... totally weird, makes no sense.... I'm still investigating.

 - Fixes pmd#234
 - When a single JVM runs multiple PMD instances under different threads,
    connections to PMD jars (and streams opened to read standard rulesets)
    are shared, causing race conditions where one thread may cause the other
    to close it's streams. This in tun produces IOExceptions.
 - This happens in Gradle when enabling parallel builds. I believe it can happen
    under Maven with -T1C too, but has not been able to reproduce it.
 - I take the chance to clean up classloader closing code, making it more concise
    and standard accross CLI and Ant.
@jsotuyod
Copy link
Member Author

jsotuyod commented Feb 3, 2017

Figured it out! Would never have guessed it... Added a nice comment for future self.

@adangel
Copy link
Member

adangel commented Feb 12, 2017

Thanks! It's merged into pmd/5.4.x, pmd/5.5.x and master branches.

adangel added a commit to adangel/pmd that referenced this pull request Feb 12, 2017
…nt Task

Got lost, when pmd#235 was rebased onto pmd/5.4.x
adangel added a commit to adangel/pmd that referenced this pull request Feb 12, 2017
…nt Task

Got lost, when pmd#235 was rebased onto pmd/5.4.x
@adangel adangel merged commit bfe0723 into pmd:master Feb 12, 2017
@jsotuyod jsotuyod deleted the issue-234 branch February 12, 2017 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:bug PMD crashes or fails to analyse a file.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[core] Zip file stream closes spuriously when loading rulesets
2 participants