Discover NullPointerException bugs using FindBug

Posted by alex2k8 on Stack Overflow See other posts from Stack Overflow or by alex2k8
Published on 2010-05-07T21:28:32Z Indexed on 2010/05/07 21:38 UTC
Read the original article Hit count: 258

Filed under:
|
|

When I run FindBug on this code, it reports NO issues.

boolean _closed = false;

public void m1(@Nullable String text) {
    if(_closed)
        return;

    System.out.println(text.toLowerCase());
}

While here it finds issue as expected:

public void m1(@Nullable String text) {
    System.out.println(text.toLowerCase());  // FireBug: text must be nonnull but is marked as nullable
}

Why does it fail in first case?

© Stack Overflow or respective owner

Related posts about java

Related posts about findbugs