hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From la...@apache.org
Subject svn commit: r1498536 - in /hbase/trunk: hbase-client/src/main/java/org/apache/hadoop/hbase/filter/DependentColumnFilter.java hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestDependentColumnFilter.java
Date Mon, 01 Jul 2013 16:01:46 GMT
Author: larsh
Date: Mon Jul  1 16:01:45 2013
New Revision: 1498536

URL: http://svn.apache.org/r1498536
Log:
HBASE-8794 DependentColumnFilter.toString() throws NullPointerException (Stefan Seelmann)

Modified:
    hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/DependentColumnFilter.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestDependentColumnFilter.java

Modified: hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/DependentColumnFilter.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/DependentColumnFilter.java?rev=1498536&r1=1498535&r2=1498536&view=diff
==============================================================================
--- hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/DependentColumnFilter.java
(original)
+++ hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/DependentColumnFilter.java
Mon Jul  1 16:01:45 2013
@@ -285,6 +285,6 @@ public class DependentColumnFilter exten
         Bytes.toStringBinary(this.columnQualifier),
         this.dropDependentColumn,
         this.compareOp.name(),
-        Bytes.toStringBinary(this.comparator.getValue()));
+        this.comparator != null ? Bytes.toStringBinary(this.comparator.getValue()) : "null");
   }
 }

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestDependentColumnFilter.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestDependentColumnFilter.java?rev=1498536&r1=1498535&r2=1498536&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestDependentColumnFilter.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestDependentColumnFilter.java
Mon Jul  1 16:01:45 2013
@@ -39,6 +39,7 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import org.junit.experimental.categories.Category;
@@ -247,5 +248,32 @@ public class TestDependentColumnFilter {
       assertEquals("check cell retention", 2, accepted.size());
   }
 
+  /**
+   * Test for HBASE-8794. Avoid NullPointerException in DependentColumnFilter.toString().
+   */
+  @Test
+  public void testToStringWithNullComparator() {
+    // Test constructor that implicitly sets a null comparator
+    Filter filter = new DependentColumnFilter(FAMILIES[0], QUALIFIER);
+    assertNotNull(filter.toString());
+    assertTrue("check string contains 'null' as compatator is null",
+      filter.toString().contains("null"));
+
+    // Test constructor with explicit null comparator
+    filter = new DependentColumnFilter(FAMILIES[0], QUALIFIER, true, CompareOp.EQUAL, null);
+    assertNotNull(filter.toString());
+    assertTrue("check string contains 'null' as compatator is null",
+      filter.toString().contains("null"));
+  }
+
+  @Test
+  public void testToStringWithNonNullComparator() {
+    Filter filter =
+        new DependentColumnFilter(FAMILIES[0], QUALIFIER, true, CompareOp.EQUAL,
+            new BinaryComparator(MATCH_VAL));
+    assertNotNull(filter.toString());
+    assertTrue("check string contains comparator value", filter.toString().contains("match"));
+  }
+
 }
 



Mime
View raw message