Ghilteras
(Angelo Pantano)
July 10, 2019, 11:38pm
1
This is the compliant solution
Optional<String> value = this.getOptionalValue();
if (value.isPresent()) { String stringValue = value.get(); }
This is my code
Optional<String> value1 = this.getOptionalValue1();
Optional<String> value2 = this.getOptionalValue2();
if ((value1.isPresent()) && (value2.isPresent())) {
func(value1.get(), value2.get());
}
This throws the warning, which looks like a False Positive to me
versions:
java8 with sonar 7.3 with sonar-java 5.12.1.17771
Hi,
Are you sure of the version of SonarJava ? this version is more than 2 years old. I would recommend to upgrade to latest version (sonarjava 5.13.1.18282 ) and let us know if the problem persists.
Ghilteras
(Angelo Pantano)
July 12, 2019, 5:48pm
3
Hi, I’m sorry the version of sonar java is actually 5.12.1.17771, I edited the post to fix it, thanks
still looks like a False Positive to me, can you guys reproduce this? It should be fairly quick to test it out
Lena
(Elena Vilchik)
July 22, 2019, 2:43pm
4
Hi,
I can’t reproduce your problem. Are you sure you provided all required details in your code snippet?