JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.

If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.

If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.

CodeSonar® 9.2p0 CONFIDENTIAL CodeSecure Inc
Java


JAVA.NULL.PARAM.LAMBDA : Lambda Parameter may be null (Java)

Summary

A parameter of a lambda expression might be null.

If null is dereferenced, Java runs into a NullPointerException. For this reason, programmers must ensure that the content of expressions dereferenced in their programs is never null.

CodeSonar provides two sets of warning classes covering various aspects of null value handling.

For the most comprehensive null pointer checking, enable both sets of warning classes: JAVA.NULL.* and JAVA.DEEPNULL.*

Strict and Non-Strict Checking

When JAVA_ANALYSIS_STRICT_MODE=No, warnings of this class will not be issued if there are indications that the possibility of a NullPointerException has been recognized and accounted for. For example, warnings will not be issued for code inside a try-catch block that explicitly catches NullPointerException, or for a JUnit test that is annotated as expecting this exception.

When JAVA_ANALYSIS_STRICT_MODE=Yes, warnings will be issued even in these cases.

Properties

Class Name Lambda Parameter may be null (Java)
Significance reliability
Mnemonic JAVA.NULL.PARAM.LAMBDA
Categories
CWE CWE:456 Missing Initialization of a Variable
Availability Available for Java and Kotlin.
Enabling Checks for this warning class are enabled by default. To disable them, add the following WARNING_FILTER rule to the project configuration file.
WARNING_FILTER += discard class="Lambda Parameter may be null (Java)"

Resolution

Check if the warning corresponds to a situation where null might actually be dereferenced at runtime. If that is the case, add a nullness check for the value being dereferenced, or change the logic of the code. Sometimes, a warning of this checker corresponds to a spurious nullness check, that can be removed.

Relevant Configuration File Parameters

The following configuration file parameters affect checks for this warning class.

 

To report problems with this documentation, please visit https://support.codesecure.com/.