Skip to content

Fix UseSLF4JLoggerRule throws NPEs with Java 10+ var type#382

Merged
kaikreuzer merged 1 commit into
openhab:masterfrom
wborn:fix-var-npe
Apr 25, 2020
Merged

Fix UseSLF4JLoggerRule throws NPEs with Java 10+ var type#382
kaikreuzer merged 1 commit into
openhab:masterfrom
wborn:fix-var-npe

Conversation

@wborn

@wborn wborn commented Mar 29, 2020

Copy link
Copy Markdown
Member

The PMD type resolution for inferred types using the var keyword 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 var can 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 UseSLF4JLoggerRule part of #380

@wborn wborn added the bug An unexpected problem or unintended behavior of the tools label Apr 5, 2020

@kaikreuzer kaikreuzer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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
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>
@kaikreuzer
kaikreuzer merged commit 2a39b2c into openhab:master Apr 25, 2020
@wborn

wborn commented Apr 25, 2020

Copy link
Copy Markdown
Member Author

I assume, everything is then ready for the new SAT release.

Yes I think it's all ready now! 🙂

@wborn
wborn deleted the fix-var-npe branch April 25, 2020 20:31
@kaikreuzer kaikreuzer added this to the 0.10.0 milestone Apr 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug An unexpected problem or unintended behavior of the tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UseSLF4JLoggerRule throws NPEs with Java 10+ var type

2 participants