From 8113855b3af913e6dcd09626953c64d43168efbd Mon Sep 17 00:00:00 2001 From: Yongjun Zhang Date: Tue, 28 Jun 2016 23:15:13 -0700 Subject: [PATCH] HDFS-10396. Using -diff option with DistCp may get "Comparison method violates its general contract" exception. Contributed by Yongjun Zhang. --- .../src/main/java/org/apache/hadoop/tools/DiffInfo.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/DiffInfo.java b/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/DiffInfo.java index 10a8b7e25c2..79bb7fe2671 100644 --- a/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/DiffInfo.java +++ b/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/DiffInfo.java @@ -38,8 +38,8 @@ class DiffInfo { static final Comparator targetComparator = new Comparator() { @Override public int compare(DiffInfo d1, DiffInfo d2) { - return d1.target == null ? -1 : - (d2.target == null ? 1 : d1.target.compareTo(d2.target)); + return d1.target == null ? ((d2.target == null)? 0 : -1) : + (d2.target == null ? 1 : d1.target.compareTo(d2.target)); } };