From 9ff90931dc5dd46432986cb64926e497fb0e1881 Mon Sep 17 00:00:00 2001 From: stack Date: Wed, 2 Jul 2014 10:06:15 -0700 Subject: [PATCH] HBASE-11413 [findbugs] RV: Negating the result of compareTo()/compare() (Mike Drob) --- .../java/org/apache/hadoop/hbase/master/CatalogJanitor.java | 6 +++--- .../org/apache/hadoop/hbase/migration/NamespaceUpgrade.java | 2 +- .../org/apache/hadoop/hbase/util/FSTableDescriptors.java | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java index 59bc01efe65..1ffec8ac0ab 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java @@ -294,10 +294,10 @@ public class CatalogJanitor extends Chore { // Compare start keys. result = Bytes.compareTo(left.getStartKey(), right.getStartKey()); if (result != 0) return result; - // Compare end keys. - result = rowEndKeyComparator.compare(left.getEndKey(), right.getEndKey()); + // Compare end keys, but flip the operands so parent comes first + result = rowEndKeyComparator.compare(right.getEndKey(), left.getEndKey()); - return -result; // Flip the result so parent comes first. + return result; } } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java index b05481340f2..daef08345d5 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java @@ -524,7 +524,7 @@ public class NamespaceUpgrade implements Tool { new Comparator() { @Override public int compare(FileStatus left, FileStatus right) { - return -left.compareTo(right); + return right.compareTo(left); }}; // logic culled from FSTableDescriptors diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSTableDescriptors.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSTableDescriptors.java index f3f29684af6..09749d0cc96 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSTableDescriptors.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSTableDescriptors.java @@ -378,7 +378,7 @@ public class FSTableDescriptors implements TableDescriptors { new Comparator() { @Override public int compare(FileStatus left, FileStatus right) { - return -left.compareTo(right); + return right.compareTo(left); }}; /**