False positive about potential null access

Getting “A “NullPointerException” could be thrown; “tb” is nullable here.” from

if (Optional.ofNullable(tb).map(val -> val.getFrom()).map(EReference.class::isInstance).orElse(false)) {
			EStructuralFeature feature = (EStructuralFeature)tb.getTo();

Error is reported on tb.getTo()

Since tb is checked with Optional for nullable and if optional is empty we return false, we can’t get to the next line and have a nullable tb

Using:
SonarLint for Eclipse 10.9.1.82333

4 posts were merged into an existing topic: False Positive for Rule java:S2259: “A NullPointerException could be thrown; map() can return null.”