diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteBufferUtils.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteBufferUtils.java index d788c70..0d70a35 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteBufferUtils.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteBufferUtils.java @@ -573,6 +573,15 @@ public final class ByteBufferUtils { } public static boolean equals(ByteBuffer buf1, int o1, int l1, ByteBuffer buf2, int o2, int l2) { + if ((l1 == 0) && (l2 == 0)) { + return true; + } + if ((l1 == 0) && (l2 != 0)) { + return false; + } + if ((l1 != 0) && (l2 == 0)) { + return false; + } // Since we're often comparing adjacent sorted data, // it's usual to have equal arrays except for the very last byte // so check that first @@ -627,6 +636,15 @@ public final class ByteBufferUtils { } public static boolean equals(ByteBuffer buf1, int o1, int l1, byte[] buf2, int o2, int l2) { + if ((l1 == 0) && (l2 == 0)) { + return true; + } + if ((l1 == 0) && (l2 != 0)) { + return false; + } + if ((l1 != 0) && (l2 == 0)) { + return false; + } // Since we're often comparing adjacent sorted data, // it's usual to have equal arrays except for the very last byte // so check that first