From 6370098e54e6d611e5db733862a321eefc1ab3c5 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Thu, 18 Jul 2019 16:21:13 +0900 Subject: [PATCH] MergeAlgorithm: Suppress Error Prone warning about reference equality Error Prone reports: [ReferenceEquality] Comparison using reference equality instead of value equality The END_EDIT instance is used as a marker, and thus it's OK to use a reference equality comparison. Factor the comparison to a method and add a suppression. Change-Id: I7d9dc1fa21f46c984787056b0b5d163e313026a6 Signed-off-by: David Pursehouse --- .../src/org/eclipse/jgit/merge/MergeAlgorithm.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeAlgorithm.java b/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeAlgorithm.java index dd42e4384..a77cb4ffb 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeAlgorithm.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeAlgorithm.java @@ -86,6 +86,11 @@ public final class MergeAlgorithm { private final static Edit END_EDIT = new Edit(Integer.MAX_VALUE, Integer.MAX_VALUE); + @SuppressWarnings("ReferenceEquality") + private static boolean isEndEdit(Edit edit) { + return edit == END_EDIT; + } + /** * Does the three way merge between a common base and two sequences. * @@ -145,7 +150,7 @@ public final class MergeAlgorithm { // iterate over all edits from base to ours and from base to theirs // leave the loop when there are no edits more for ours or for theirs // (or both) - while (theirsEdit != END_EDIT || oursEdit != END_EDIT) { + while (!isEndEdit(theirsEdit) || !isEndEdit(oursEdit)) { if (oursEdit.getEndA() < theirsEdit.getBeginA()) { // something was changed in ours not overlapping with any change // from theirs. First add the common part in front of the edit