False positive with Objects.requireNonNullElse and S2259

Running analysis on a Java source file in Sonarcloud returns the following issue:

This is a clear false positive because Objects.requireNonNullElse will never return null. It will throw an exception on its own if both arguments are null but this is not what the rule complains about.

Thanks for the feedback @sithmein

Indeed this is a Felsepositive because we don’t consider this method in the rule. Here is a ticket to fix it:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.