GeezerVison is showing github.com — [core] Close ZIP data sources even if a runtime exception or error is thrown by gibarsin · Pull Request #2432 · pmd/pmd
Conversation
gibarsin
commented
Apr 23, 2020
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Describe the PR
In AbstractPMDProcessor.processFiles, data sources may not be closed when a runtime exception or error is thrown. A few examples of when this could happen are:
|
throw new RuntimeException(ioe); |
|
if (t instanceof RuntimeException) { |
|
throw (RuntimeException) t; |
|
} else if (t instanceof Error) { |
|
throw (Error) t; |
|
} else { |
|
throw new IllegalStateException("PmdRunnable exception", t); |
A "try finally" (not a try with resources) block has been added such that the finally statement closes quietly the data sources.
Changes are best seen with "Hide whitespace changes" enabled.
Related issues
Ready?
- Added unit tests for fixed bug/feature
- Passing all unit tests
- Complete build
./mvnw clean verify passes (checked automatically by travis)
- Added (in-code) documentation (if needed)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
1 Message
|
| 📖 |
No java rules are changed! |
Generated by 🚫 Danger
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
adangel
changed the title
[core] Close data sources even if a runtime exception or error is thrown in AbstractPMDProcessor.processFiles
[core] Close ZIP data sources even if a runtime exception or error is thrown in AbstractPMDProcessor.processFiles
Apr 24, 2020
adangel
commented
Apr 24, 2020
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
Agreed - be aware, that this only affects ZIP data sources and exceptions, that are thrown by renderers/during reporting.
The single files themselves are opened already via a try-with-resources:
|
try (InputStream stream = new BufferedInputStream(dataSource.getInputStream())) { |
I'll rebase this PR onto master, since it's a bugfix.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
adangel
changed the title
[core] Close ZIP data sources even if a runtime exception or error is thrown in AbstractPMDProcessor.processFiles
[core] Close ZIP data sources even if a runtime exception or error is thrown
Apr 24, 2020
adangel
added a commit
that referenced
this pull request
Apr 24, 2020
[core] Close ZIP data sources even if a runtime exception or error is thrown #2432
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
a:bug
PMD crashes or fails to analyse a file.
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.