Wrong NPE reported

See https://sonarqube.ow2.org/project/issues?id=org.xwiki.platform%3Axwiki-platform&open=AW48MMemd67NGAIshsVO&resolved=false&types=BUG

SQ says that getXARExtensionPlan().containsNewPages() could throw a NPE but in practice it’s not possible since we check for null just before with getXARExtensionPlan() != null in if (currentJob.getStatus().getRequest().isInteractive() && getXARExtensionPlan() != null && getXARExtensionPlan().containsNewPages()) {.

Am I missing something or is it a limitation/bug?


Your getXARExtensionPlan() is not a simple getter but in fact seems rather complex. Even if the first invocation may return a non-null value, the second invocation might still return a null value. If you stored the result of the first invocation in a local variable and checked on that, it would probably not raise the issue. And as added bonus, you save some redundant instructions.

1 Like

Good point. Thanks.

FWIW, fixed in https://github.com/xwiki/xwiki-platform/commit/c84b2c8bfa46db09ea021618d745ef08e193a571