== Why is this an issue?

Inexperienced Java developers might expect the ``++Object.equals(Object obj)++`` method to correctly handle the case where the left hand side is null, but that is not the case.


=== Noncompliant code example

[source,text]
----
if (variable.equals(null)) { /* ... */ }   // Noncompliant - "variable" is really null, a NullPointerException is thrown
----


=== Compliant solution

[source,text]
----
if (variable == null) { /* ... */ }        // Compliant
----


ifdef::env-github,rspecator-view[]

'''
== Comments And Links
(visible only on this page)

=== relates to: S2220

=== on 15 Oct 2013, 09:05:54 Freddy Mallet wrote:
Is implemented by \http://jira.codehaus.org/browse/SONARJAVA-360

=== on 2 Feb 2015, 20:28:35 Sébastien Gioria wrote:
Part of OWASP Top10 2013 A6

=== on 3 Feb 2015, 20:21:52 Ann Campbell wrote:
I don't understand the relationship [~sebastien.gioria]


endif::env-github,rspecator-view[]
