Menu

#1372 NP_LOAD_OF_KNOWN_NULL_VALUE raised incorrectly

3.x
closed-fixed
5
2015-04-13
2015-03-26
Rob Martin
No

Getting NP_LOAD_OF_KNOWN_NULL_VALUE raised with the following code:

public class FbNullCheck {
    public void test(final boolean test) {
        String s = null;
        try {
            if (test) {
                return;
            }
            throw new IllegalStateException("Illegal Exception");
        } catch (final Exception e) {
            s = "test";
            throw new RuntimeException("Runtime Exception", e);
        } finally {
            method(s);
        }
    }

    private void method (final String method) {
    }
}

When method() is called s can be a not null value if test=false so that the IllegalStateException is raise, caught by the catch and s assigned.

Discussion

  • Tagir Valeev

    Tagir Valeev - 2015-03-28

    This detector relies on Line Number debug info during the analysis of finally blocks. Are you compiling with debug information? It's always recommended to switch on the debug information when using FindBugs.

     
  • William Pugh

    William Pugh - 2015-04-13

    thanks. Fixed.

     
  • William Pugh

    William Pugh - 2015-04-13
    • status: open --> closed-fixed
    • assigned_to: William Pugh
     

Log in to post a comment.

MongoDB Logo MongoDB