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: support Lombok's @Cleanup annotation · Issue #2757 · pmd/pmd

[java] CloseResource: support Lombok's @Cleanup annotation #2757

New issue
Copy link
New issue
Copy link
Closed
#3197
Closed
[java] CloseResource: support Lombok's @Cleanup annotation#2757
#3197
Copy link
Labels
a:false-positivePMD flags a piece of code that is not problematican:enhancementAn improvement on existing features / rules
Milestone
6.34.0

Description

@TomerFi
TomerFi
opened on Sep 1, 2020
Issue body actions

Affects PMD Version:

6.27.0

Description:

Version 6.27.0 breaks support for Lombok's Cleanup Annotation which generates invocation of the close() method for closable objects.

Falling back to 6.26.0 works as expected by not producing the same violation.

Exception Stacktrace:

<violation ... rule="CloseResource" ruleset="Error Prone" ... class="ShabbatTimesStreamHandler" method="getCreator" variable="context" externalInfoUrl="https://pmd.github.io/pmd-6.27.0/pmd_rules_java_errorprone.html#closeresource" priority="3">
Ensure that resources like this AnnotationConfigApplicationContext object are closed after use
</violation>

Code Sample demonstrating the issue:

Copied from a public repository: TomerFi/alexa-skill-shabbat-times

public class ShabbatTimesStreamHandler extends SkillStreamHandler {
  private static ShabbatTimesSkillCreator getCreator() {
    @Cleanup val context = new AnnotationConfigApplicationContext(DiProdConfiguration.class);
    return context.getBean(ShabbatTimesSkillCreator.class);
  }

  public ShabbatTimesStreamHandler() {
    super(getCreator().getSkill());
  }
}

Steps to reproduce:

Please provide detailed steps for how we can reproduce the bug.

  1. clone the repository:
git clone https://github.com/TomerFi/alexa-skill-shabbat-times.git
  1. step into the cloned folder:
cd alexa-skill-shabbat-times
  1. invoke maven goal (no violation is detected with version 6.26.0):
mvn pmd:check
  1. update the pmd.version property in pom.xml to 6.27.0 to catch the violation:
  <properties>
   ...
    <pmd.version>6.27.0</pmd.version>
   ...
  </properties>
  1. invoke maven goal
mvn pmd:check

will now produce:

You have 1 PMD violation.

Running PMD through: Maven

Activity

  1. TomerFi
    added
    a:bugPMD crashes or fails to analyse a file.
    on Sep 1, 2020
  2. acranmer commented on Dec 2, 2020

    @acranmer
    acranmer
    on Dec 2, 2020
    More actions

    I noticed it broke for me with 6.16.0

  3. oowekyala commented on Apr 5, 2021

    @oowekyala
    oowekyala
    on Apr 5, 2021
    Member
    More actions

    I wonder if this was fixed by #3157

  4. oowekyala
    changed the title [-][java] PMD 6.27.0 break support for Lombok's Cleanup annotation[/-] [+][java] PMD 6.27.0 bug with Lombok's Cleanup annotation[/+] on Apr 5, 2021
  5. oowekyala commented on Apr 5, 2021

    @oowekyala
    oowekyala
    on Apr 5, 2021
    Member
    More actions

    After investigating, this problem is still there on master. But that's because the rule never had support for lombok's @Cleanup in the first place. So, this needs to be added to the rule.

    Reacted by Andreas Dangel
  6. oowekyala
    changed the title [-][java] PMD 6.27.0 bug with Lombok's Cleanup annotation[/-] [+][java] PMD 6.27.0 support Lombok's @Cleanup annotation[/+] on Apr 5, 2021
  7. oowekyala
    added
    a:false-negativePMD doesn't flag a problematic piece of code
    an:enhancementAn improvement on existing features / rules
    and removed
    a:bugPMD crashes or fails to analyse a file.
    on Apr 5, 2021
  8. oowekyala
    changed the title [-][java] PMD 6.27.0 support Lombok's @Cleanup annotation[/-] [+][java] CloseResource: support Lombok's @Cleanup annotation[/+] on Apr 5, 2021
  9. oowekyala
    added 3 commits that reference this issue on Apr 5, 2021

    Add test case for pmd#2757

    1a095f9

    CloseResource: Add support for @lombok.Cleanup

    cfb6b3d
  10. oowekyala
    added this to the 6.34.0 milestone on Apr 5, 2021
  11. oowekyala
    added
    a:false-positivePMD flags a piece of code that is not problematic
    and removed
    a:false-negativePMD doesn't flag a problematic piece of code
    on Apr 5, 2021
  12. adangel
    closed this as completedin cfb6b3don Apr 10, 2021
  13. adangel
    closed this as completedin #3197on Apr 10, 2021
  14. adangel
    added 2 commits that reference this issue on Apr 10, 2021

    [doc] Update release notes, refs #2757, refs #3197

    872b69d

    Merge pull request #3197 from

    a55f760
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 problematican:enhancementAn improvement on existing features / rules

    Type

    No type

    Projects

    No projects

      Milestone

      • 6.34.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.