diff --git a/CHANGES.txt b/CHANGES.txt index cd2c8d1e994..3e62f4b1fc2 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -877,6 +877,7 @@ Release 0.92.0 - 01/23/2012 Release 0.90.7 - Unreleased BUG FIXES + HBASE-5271 Result.getValue and Result.getColumnLatest return the wrong column (Ghais Issa) Release 0.90.6 - Unreleased diff --git a/src/main/java/org/apache/hadoop/hbase/KeyValue.java b/src/main/java/org/apache/hadoop/hbase/KeyValue.java index 603b13ecd38..b8fb08556b2 100644 --- a/src/main/java/org/apache/hadoop/hbase/KeyValue.java +++ b/src/main/java/org/apache/hadoop/hbase/KeyValue.java @@ -1277,7 +1277,7 @@ public class KeyValue implements Writable, HeapSize { int o = getFamilyOffset(rl); int fl = getFamilyLength(o); int ql = getQualifierLength(rl,fl); - if (!Bytes.equals(family, 0, family.length, this.bytes, o, family.length)) { + if (!Bytes.equals(family, 0, family.length, this.bytes, o, fl)) { return false; } if (qualifier == null || qualifier.length == 0) { diff --git a/src/test/java/org/apache/hadoop/hbase/TestKeyValue.java b/src/test/java/org/apache/hadoop/hbase/TestKeyValue.java index 3ef9f209aee..f97d2bab3df 100644 --- a/src/test/java/org/apache/hadoop/hbase/TestKeyValue.java +++ b/src/test/java/org/apache/hadoop/hbase/TestKeyValue.java @@ -56,6 +56,21 @@ public class TestKeyValue extends TestCase { assertFalse(aaa.matchingColumn(family2,qualifier2)); } + /** + * Test a corner case when the family qualifier is a prefix of the + * column qualifier. + */ + public void testColumnCompare_prefix() throws Exception { + final byte [] a = Bytes.toBytes("aaa"); + byte [] family1 = Bytes.toBytes("abc"); + byte [] qualifier1 = Bytes.toBytes("def"); + byte [] family2 = Bytes.toBytes("ab"); + byte [] qualifier2 = Bytes.toBytes("def"); + + KeyValue aaa = new KeyValue(a, family1, qualifier1, 0L, Type.Put, a); + assertFalse(aaa.matchingColumn(family2, qualifier2)); + } + public void testBasics() throws Exception { LOG.info("LOWKEY: " + KeyValue.LOWESTKEY.toString()); check(Bytes.toBytes(getName()),