Fix UseSLF4JLoggerRule throws NPEs with Java 10+ var type#382
Merged
Conversation
kaikreuzer
approved these changes
Apr 25, 2020
kaikreuzer
left a comment
Member
There was a problem hiding this comment.
Thanks, lgtm.
Could you please rebase it on master and remove the draft status?
I assume, everything is then ready for the new SAT release.
wborn
marked this pull request as ready for review
April 25, 2020 20:23
The PMD type resolution for inferred types using the `var` keyword is very simple (see [Java 10 Support](https://pmd.github.io/latest/pmd_release_notes_old.html#java-10-support). As a result it's usually not possible to get the type of such variables during analysis. So for now it's probably best to make sure not any NPEs occur whenever the type cannot be inferred. Since `var` can only be used with local variables, it's not likely loggers will be instantiated often this way. Fixes openhab#379 Signed-off-by: Wouter Born <github@maindrain.net>
Member
Author
Yes I think it's all ready now! 🙂 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The PMD type resolution for inferred types using the
varkeyword is very simple (see Java 10 Support).As a result it's usually not possible to get the type of such variables during analysis.
So for now it's probably best to make sure not any NPEs occur whenever the type cannot be inferred.
Since
varcan only be used with local variables, it's not likely loggers will be instantiated often this way.Fixes #379
Draft because this builds upon the changes made in
UseSLF4JLoggerRulepart of #380