]> source.dussan.org Git - jgit.git/commitdiff
[spotbugs] Fix FileReftableStack#equals to check for null 77/173377/7
authorMatthias Sohn <matthias.sohn@sap.com>
Fri, 4 Dec 2020 10:21:08 +0000 (11:21 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Tue, 22 Dec 2020 09:52:59 +0000 (10:52 +0100)
This fixes spotbugs warning NP_EQUALS_SHOULD_HANDLE_NULL_ARGUMENT.

This implementation violated the contract defined by
java.lang.Object.equals() because it did not check for null being passed
as the argument. All equals() methods should return false if passed a
null value.

Change-Id: I607f6979613d390aae2f3546b587f63133d6d73c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileReftableStack.java

index bc2039c56b12ff998b46badfde314880392f0f52..db454b92b8df97b15c3c5edf62c4f51aeca39d7d 100644 (file)
@@ -636,6 +636,9 @@ public class FileReftableStack implements AutoCloseable {
 
                @Override
                public boolean equals(Object other) {
+                       if (other == null) {
+                               return false;
+                       }
                        Segment o = (Segment) other;
                        return o.bytes == bytes && o.log == log && o.start == start
                                        && o.end == end;