From bac0e8fd8d7b8a5b70009346d3ccbd5f2a3a2a5b Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Fri, 9 Aug 2019 01:01:27 +0200 Subject: [error prone] fix ReferenceEquality warning in static equals methods Implement a helper method suppressing the ReferenceEquality error prone warning and use it to fix this warning in static equals methods where this comparison is used to implement fast path of static equals implementation. See https://errorprone.info/bugpattern/ReferenceEquality Change-Id: I33538a3406007d24efec3a504e031ca1069572ed Signed-off-by: Matthias Sohn --- .../src/org/eclipse/jgit/lfs/lib/AnyLongObjectId.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'org.eclipse.jgit.lfs/src/org/eclipse/jgit') diff --git a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/lib/AnyLongObjectId.java b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/lib/AnyLongObjectId.java index e6fe7408a8..0a509acb79 100644 --- a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/lib/AnyLongObjectId.java +++ b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/lib/AnyLongObjectId.java @@ -50,6 +50,7 @@ import java.nio.ByteBuffer; import org.eclipse.jgit.lib.AnyObjectId; import org.eclipse.jgit.util.NB; +import org.eclipse.jgit.util.References; /** * A (possibly mutable) SHA-256 abstraction. @@ -76,8 +77,9 @@ public abstract class AnyLongObjectId implements Comparable { */ public static boolean equals(final AnyLongObjectId firstObjectId, final AnyLongObjectId secondObjectId) { - if (firstObjectId == secondObjectId) + if (References.isSameObject(firstObjectId, secondObjectId)) { return true; + } // We test word 2 first as odds are someone already used our // word 1 as a hash code, and applying that came up with these -- cgit v1.2.3