But SonarQube/SonarLint gives me java:S3655 as a major bug, although it is obviously the first check in the chain.
Happens locally aswell as on our deployed version.
My guess is, that this is a bug of Sonar…
Has anyone else experienced this issue?
Our analyzer is not able to detect if dto.getStructure() always returns the same object. It looks like a getter, but in Java this is just convention, and the field behind could possibly be changed by a concurrent thread.
will make one step in the right direction, but then I think you are likely to get another issue for a similar reason because of the two consecutive calls of getCompositionType(). The result can be non-null the first time, and null the second time.
So in the end, you have no choice than introducing another intermediate variable. This will make your code more thread safe. Something like: