[Java] optional.orElseGet(null) produces a null pointer exception

Hello Jérémie,

Thanks for having raised this case. My suggestion is to enhance the rule S2259: Null pointers should not be dereferenced so that it raises an issue on Optional.orElseGet(null).

Here is the related ticket: https://jira.sonarsource.com/browse/SONARJAVA-2916

Regards

1 Like