GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

@gibarsin gibarsin commented Apr 23, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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:

  • pmd/pmd-core/src/main/java/net/sourceforge/pmd/processor/AbstractPMDProcessor.java

    Line 51 in bfa4fd3

    throw new RuntimeException(ioe);
  • pmd/pmd-core/src/main/java/net/sourceforge/pmd/processor/MultiThreadProcessor.java

    Lines 52 to 57 in 0942ae3

    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.

All reactions
gibarsin
Close data sources even if a runtime exception or error is thrown in …
bfa4fd3
…processFiles
@ghost

ghost commented Apr 23, 2020

Copy link
Copy Markdown
1 Message
📖 No java rules are changed!

Generated by 🚫 Danger

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@adangel 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

adangel commented Apr 24, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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:

pmd/pmd-core/src/main/java/net/sourceforge/pmd/processor/PmdRunnable.java

Line 76 in 96e9127

try (InputStream stream = new BufferedInputStream(dataSource.getInputStream())) {

I'll rebase this PR onto master, since it's a bugfix.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@adangel adangel added the a:bug PMD crashes or fails to analyse a file. label Apr 24, 2020
@adangel adangel added this to the 6.23.0 milestone Apr 24, 2020
@adangel 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 adangel closed this in eb68732 Apr 24, 2020
adangel added a commit that referenced this pull request Apr 24, 2020
@adangel
Merge branch 'pr-2432'
0e40a06
[core] Close ZIP data sources even if a runtime exception or error is thrown #2432
@adangel adangel modified the milestone: 6.23.0 Apr 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

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.

Projects

None yet

Milestone

6.23.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@gibarsin @adangel
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.