Boxed boolean from a hashMap

Rule java:S5411

Map<String, Boolean> hasAccess = new HashMap<>();
if (hasAccess.computeIfAbsent("foo", k -> false)) {
}

This code raises a complaint about a Boxed boolean, but there’s no actual way to avoid it. You can’t create a Map with a boolean, only a Boolean.

Also the proposed fix does:

if ( Boolean.TRUE.equals(hasAccess.computeIfAbsent("foo", k -> false))) {

Which, first of all doesn’t seem at all better, and second still gives the same warning!

Hey there.

What version(s) of which product(s) are you using?

I believe it’s version 10.6 but I’m not 100% sure, because I’m not sure if the version of the plugin is different from the SonarLint backend.