Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[java] Fix NPE in CloseResourceRule #4356

Merged
merged 2 commits into from
Jan 30, 2023
Merged

Conversation

jsotuyod
Copy link
Member

@jsotuyod jsotuyod commented Jan 25, 2023

Rule: CloseResource

Describe the PR

When using type inference and initializing through a method call rather than a direct constructor call, the rule would detect the var as being a Closeable, yet fail to retrieve the proper type to check if it was whitelisted / which error message to produce.

We now look at wether there is type inference in play when deciding wether computing the runtime type is required.

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

 - Type inference now leads to runtime types being used, even if it's on a MethodCall expression
@jsotuyod jsotuyod added the a:bug PMD crashes or fails to analyse a file. label Jan 25, 2023
@jsotuyod jsotuyod added this to the 7.0.0 milestone Jan 25, 2023
@pmd-test
Copy link

2 Messages
📖 Compared to pmd/7.0.x:
This changeset changes 0 violations,
introduces 141 new violations, 1 new errors and 0 new configuration errors,
removes 0 violations, 1447 errors and 0 configuration errors.
Full report
📖 Compared to master:
This changeset changes 52 violations,
introduces 9 new violations, 2 new errors and 0 new configuration errors,
removes 72 violations, 6 errors and 7 configuration errors.
Full report

Generated by 🚫 Danger

Copy link
Member

@adangel adangel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@adangel adangel merged commit 0547d90 into pmd/7.0.x Jan 30, 2023
@jsotuyod jsotuyod deleted the fix-closeresource-rule branch January 30, 2023 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:bug PMD crashes or fails to analyse a file.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants