Merge branch 'pr-2432'
[core] Close ZIP data sources even if a runtime exception or error is thrown #2432
This commit is contained in:
@ -74,6 +74,7 @@ See [the documentation and example](https://pmd.github.io/latest/pmd_userdocs_re
|
||||
* [#2019](https://github.com/pmd/pmd/issues/2019): \[core] Insufficient deprecation warnings for XPath attributes
|
||||
* [#2357](https://github.com/pmd/pmd/issues/2357): Add code of conduct: Contributor Covenant
|
||||
* [#2426](https://github.com/pmd/pmd/issues/2426): \[core] CodeClimate renderer links are dead
|
||||
* [#2432](https://github.com/pmd/pmd/pull/2432): \[core] Close ZIP data sources even if a runtime exception or error is thrown
|
||||
* doc
|
||||
* [#2355](https://github.com/pmd/pmd/issues/2355): \[doc] Improve documentation about incremental analysis
|
||||
* [#2356](https://github.com/pmd/pmd/issues/2356): \[doc] Add missing doc about pmd.github.io
|
||||
@ -200,6 +201,7 @@ In the **Java AST** the following attributes are deprecated and will issue a war
|
||||
* [#2409](https://github.com/pmd/pmd/pull/2409): \[java] ClassNamingConventions suggests to add Util for class containing only static constants, fixes #1164 - [Binu R J](https://github.com/binu-r)
|
||||
* [#2411](https://github.com/pmd/pmd/pull/2411): \[java] Fix UseAssertEqualsInsteadOfAssertTrue Example - [Moritz Scheve](https://github.com/Blightbuster)
|
||||
* [#2423](https://github.com/pmd/pmd/pull/2423): \[core] Fix Checkstyle OperatorWrap in AbstractTokenizer - [Harsh Kukreja](https://github.com/harsh-kukreja)
|
||||
* [#2432](https://github.com/pmd/pmd/pull/2432): \[core] Close ZIP data sources even if a runtime exception or error is thrown - [Gonzalo Exequiel Ibars Ingman](https://github.com/gibarsin)
|
||||
|
||||
{% endtocmaker %}
|
||||
|
||||
|
@ -110,27 +110,29 @@ public abstract class AbstractPMDProcessor {
|
||||
// this is done manually without a try-with-resources
|
||||
public void processFiles(RuleSetFactory ruleSetFactory, List<DataSource> files, RuleContext ctx,
|
||||
List<Renderer> renderers) {
|
||||
final RuleSets rs = createRuleSets(ruleSetFactory, ctx.getReport());
|
||||
configuration.getAnalysisCache().checkValidity(rs, configuration.getClassLoader());
|
||||
final SourceCodeProcessor processor = new SourceCodeProcessor(configuration);
|
||||
try {
|
||||
final RuleSets rs = createRuleSets(ruleSetFactory, ctx.getReport());
|
||||
configuration.getAnalysisCache().checkValidity(rs, configuration.getClassLoader());
|
||||
final SourceCodeProcessor processor = new SourceCodeProcessor(configuration);
|
||||
|
||||
for (final DataSource dataSource : files) {
|
||||
// this is the real, canonical and absolute filename (not shortened)
|
||||
String realFileName = dataSource.getNiceFileName(false, null);
|
||||
for (final DataSource dataSource : files) {
|
||||
// this is the real, canonical and absolute filename (not shortened)
|
||||
String realFileName = dataSource.getNiceFileName(false, null);
|
||||
|
||||
runAnalysis(new PmdRunnable(dataSource, realFileName, renderers, ctx, rs, processor));
|
||||
}
|
||||
runAnalysis(new PmdRunnable(dataSource, realFileName, renderers, ctx, rs, processor));
|
||||
}
|
||||
|
||||
// render base report first - general errors
|
||||
renderReports(renderers, ctx.getReport());
|
||||
// render base report first - general errors
|
||||
renderReports(renderers, ctx.getReport());
|
||||
|
||||
// then add analysis results per file
|
||||
collectReports(renderers);
|
||||
|
||||
// in case we analyzed files within Zip Files/Jars, we need to close them after
|
||||
// the analysis is finished
|
||||
for (DataSource dataSource : files) {
|
||||
IOUtils.closeQuietly(dataSource);
|
||||
// then add analysis results per file
|
||||
collectReports(renderers);
|
||||
} finally {
|
||||
// in case we analyzed files within Zip Files/Jars, we need to close them after
|
||||
// the analysis is finished
|
||||
for (DataSource dataSource : files) {
|
||||
IOUtils.closeQuietly(dataSource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user