Commit 2a39b2c
authored
Fix UseSLF4JLoggerRule throws NPEs with Java 10+ var type (#382)
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 #379
Signed-off-by: Wouter Born <github@maindrain.net>1 parent 5bb51f3 commit 2a39b2c
2 files changed
Lines changed: 28 additions & 13 deletions
File tree
- custom-checks/pmd/src
- main/java/org/openhab/tools/analysis/pmd
- test/resources/org/openhab/tools/analysis/pmd/test/xml
Lines changed: 10 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
66 | 67 | | |
67 | | - | |
68 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
69 | 71 | | |
70 | 72 | | |
71 | 73 | | |
| |||
Lines changed: 18 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
68 | | - | |
69 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| |||
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
192 | | - | |
193 | | - | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
194 | 207 | | |
195 | 208 | | |
0 commit comments