False positive for generic casting (java:S1612) in Sonar Qube Version 8.9.7 (build 52159)

I’m seeing a false positive violation for generic casting in SonarQube Version 8.9.7 (build 52159). We were running a previous build 8.6 and did not see this issue there. I’ve verified that as shown below that the project is being picked up by Sonar as Java 8.

[INFO] Sensor JavaSquidSensor [java]
[INFO] Configured Java source version (sonar.java.source): 8

Example (false positive java:S1612 on last line):

Optional<Map<String, Boolean>> toggles = Optional
    .ofNullable(myArgs.get(0))
    .flatMap(obj -> someMethod(obj, Another.class))
    .map(obj -> (Map<String, Boolean>)obj);

This issue seems to be similar to what was pointed out in the following places:

Hey @Jeff_Pierson,

Thank you for reporting the issue. I tried to reproduce the FP and indeed, the Java analyzer wrongly reports it on SQ 8.9.X LTS. The analyzer however does not report it anymore starting from SonarQube 9.2.

The FP has been fixed by the ticket you already mentioned (SONARJAVA-4040), but unfortunately for you, it has only been shipped version 7.4 of the Java Analyuer, itself embedded in SQ 9.2 and deployed on SonarCloud. Such fixes are not backported to LTS.

In order to benefit from the latest fixes and improvements of the Java analyzer, you will have to upgrade to latest release of SonarQube (9.3 so far, 9.4 expected very soon).

Hope this helps,
Michael