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 — [java] CloseResource false positive when resource included in return value · Issue #2470 · pmd/pmd

[java] CloseResource false positive when resource included in return value #2470

New issue
Copy link
New issue
Copy link
Closed
#2671
Closed
[java] CloseResource false positive when resource included in return value#2470
#2671
Copy link
Labels
a:false-positivePMD flags a piece of code that is not problematic
Milestone
6.27.0

Description

@OverDrone
OverDrone
opened on May 6, 2020
Issue body actions

Affects PMD Version: ???

Rule: CloseResource

Description:

false positive when resource included in return value.

Code Sample demonstrating the issue:

Spring MVC controller method:

public ResponseEntity<StreamingResponseBody> test() throws IOException {
  final InputStream is = Files.newInputStream(Paths.get("..."));
  return ResponseBody.ok(os -> {
    try {
      is.transferTo(os);
    } finally {
      is.close();
    }
  });
}

Expected outcome:

  • Does PMD report a violation, where there shouldn't be one? -> false-positive

Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other] ????

Activity

  1. OverDrone
    added
    a:bugPMD crashes or fails to analyse a file.
    on May 6, 2020
  2. adangel
    added
    a:false-positivePMD flags a piece of code that is not problematic
    on May 8, 2020
  3. adangel
    removed
    a:bugPMD crashes or fails to analyse a file.
    on Jul 31, 2020
  4. adangel
    added this to the 6.27.0 milestone on Aug 20, 2020
  5. adangel
    added a commit that references this issue on Aug 20, 2020

    [doc] Update release notes, fixes pmd#2470, refs pmd#2671

    This issue will close once commit 61ba8ef is merged into the 'master' branch.
    61ba8ef
  6. adangel
    closed this as completedin 61ba8efon Aug 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:false-positivePMD flags a piece of code that is not problematic

    Type

    No type

    Projects

    No projects

      Milestone

      • 6.27.0

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      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.