Menu

#1261 False NP_LOAD_OF_KNOWN_NULL_VALUE

3.0.0
closed-fixed
5
2014-04-04
2014-03-26
No

v2.0.3: False NP_LOAD_OF_KNOWN_NULL_VALUE
False load-of-null-variable warning on the last brace in the following construct - that is, inside the implicit finally-block. However, try-with-resource DO have a null-check, so this should be perfectly valid (and it does work!)

:::java
try (InputStream inputStream = servletContext.getResourceAsStream("/META-INF/MANIFEST.MF")) {
    if (inputStream == null) {
        return "#InDevelopment#";
    }
    return new Manifest(inputStream).getMainAttributes().getValue("Implementation-Version");
}

Discussion

  • William Pugh

    William Pugh - 2014-04-04
    • labels: --> false positive
    • status: open --> open-accepted
    • assigned_to: William Pugh
     
  • William Pugh

    William Pugh - 2014-04-04
    • status: open-accepted --> closed-fixed
    • Group: 2.0.3 --> 3.0.0
     

Log in to post a comment.

MongoDB Logo MongoDB