better way to handle this is to store the result of method invocation in a variable. There is no guarantee that subsequent invocations are returning the same value, that’s why issue is raised.
This likely means that you’re on an ancient version of the Java analyzer. There’d be huge value in jumping onto the latest version of the ecosystem (notably SonarQube), and benefit from all latest analyzers (e.g. the Java one). (in the meantime, in case of any other false-positive suspicion, make sure to check those latest versions as bunch of improvements are regularly released)