openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.88k stars 3.58k forks source link

Upgrade lastnpe EEA to 2.4.0 #10396

Closed wborn closed 2 months ago

wborn commented 3 years ago

There is a new release we should upgrade to:

https://github.com/lastnpe/eclipse-null-eea-augments/releases/tag/v2.3.0

I already upgraded to this version in the other repos. For the add-ons it is a bit more work.

The reason is that the new version fixes that Optional.orElse can return null values (based on the parameter). There is quite some code using Optional.orElse expecting the result to be non-null.

One way could be to use a workaround like enclosing such statements with Objects.requireNonNull(..).

Another fix could be to rewrite such code to not use optionals. IMHO we should use only one way to prevent NPEs (the annotations) and use Optionals only where they make sense such as with Streams.

WDYT @openhab/add-ons-maintainers?

lsiepel commented 1 year ago

Version 2.4.0 release: https://github.com/lastnpe/eclipse-null-eea-augments/releases/tag/v2.4.0 Isn't this allready upgraded?

wborn commented 1 year ago

No see:

https://github.com/openhab/openhab-addons/blob/dbaf081daa477af222f8078e0b8a0b9ac535e296/pom.xml#L74

lsiepel commented 1 year ago

Well, i'm no maintainer, but i would suggest we upgrade this as part of 4.0.0? Especially because binding codeowners might refactor their bindings to move to java 17. A good moment to also check these null annotations

lsiepel commented 3 months ago

Can we somehow prevent lastnpe to check 3rdparty libs?

\bundles\org.openhab.binding.smsmodem\src\3rdparty\java\org\smslib\driver\AbstractModemDriver.java:[66,42] Null type mismatch: required 'java.io.@NonNull InputStream' but the provided value is inferred as @org.eclipse.jdt.annotation.Nullable

wborn commented 3 months ago

Can we somehow prevent lastnpe to check 3rdparty libs?

It's a compilation error generated by the compiler and AFAIK you can't disable these for certain dirs/files or use some annotation to suppress them.