False positive java:S2259: NullpointerException

The following stripped down code looks like a false positive:

(Problem in a.toAbsolutePath())


Raw code:

import org.apache.commons.lang3.Validate;
import java.nio.file.Path;
import java.nio.file.Paths;
import BaseException;

    private void x() {
        final var a = Paths.get("");
        try {
        } catch (final Exception e) {

    private void y(final Path b) throws BaseException {

My work-around is currently assert b != null; which removes the problem, but has the same effect for me. Changing Exception to BaseException would also remove it, but in this I need also to catch all Exceptions.

  • Community Edition
  • Version 9.5 (build 56709)

Best Regards,

Hey there.

I’ve moved your post to the section on reporting false-positives.

Please make sure you’ve included all information, including which product(s) you’re using and what version(s).