A reference to ``++null++`` should never be dereferenced/accessed. Doing so will cause a ``++NullPointerException++`` to be thrown. At best, such an exception will cause abrupt program termination. At worst, it could expose debugging information that would be useful to an attacker, or it could allow an attacker to bypass security measures.
Note that when they are present, this rule takes advantage of ``++@CheckForNull++`` and ``++@Nonnull++`` annotations defined in https://jcp.org/en/jsr/detail?id=305[JSR-305] to understand which values are and are not nullable except when ``++@Nonnull++`` is used on the parameter to ``++equals++``, which by contract should always work with null.
=== on 24 Mar 2015, 12:47:38 Samuel Mercier wrote:
first example is wrong, since ``++instanceof++`` would return ``++false++`` if ``++obj++`` is ``++null++``.
Interestingly, from null/notnull point of view, ``++a instanceof b++`` is equivalent to ``++a != null++``
=== on 24 Mar 2015, 13:45:55 Samuel Mercier wrote:
\[~ann.campbell.2] I updated the first non compliant code snippet.
=== on 24 Mar 2015, 15:02:13 Samuel Mercier wrote:
Removed message * NullPointerException will be thrown as 'XXXX' is for sure null here, since we are currently unable to make distinction between @Nullable and if (... == null)
=== on 19 Sep 2019, 05:14:31 QXO wrote:
This code shouldnot should not be a issue ( in `url.substring(0,start)` url never not null)
It's sonarqube(7.9.1) check implements issue, please fix the issue:)
----
public String testSonarNullCheckIssue(final String url,final boolean isUrl) {