hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From la...@apache.org
Subject svn commit: r1498537 - in /hbase/branches/0.94/src: main/java/org/apache/hadoop/hbase/filter/DependentColumnFilter.java test/java/org/apache/hadoop/hbase/filter/TestDependentColumnFilter.java
Date Mon, 01 Jul 2013 16:03:03 GMT
Author: larsh
Date: Mon Jul  1 16:03:03 2013
New Revision: 1498537

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

Modified:
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/filter/DependentColumnFilter.java
    hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/filter/TestDependentColumnFilter.java

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/filter/DependentColumnFilter.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/filter/DependentColumnFilter.java?rev=1498537&r1=1498536&r2=1498537&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/filter/DependentColumnFilter.java
(original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/filter/DependentColumnFilter.java
Mon Jul  1 16:03:03 2013
@@ -245,6 +245,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/branches/0.94/src/test/java/org/apache/hadoop/hbase/filter/TestDependentColumnFilter.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/filter/TestDependentColumnFilter.java?rev=1498537&r1=1498536&r2=1498537&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/filter/TestDependentColumnFilter.java
(original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/filter/TestDependentColumnFilter.java
Mon Jul  1 16:03:03 2013
@@ -243,6 +243,31 @@ public class TestDependentColumnFilter e
       assertEquals("check cell retention", 2, accepted.size());
   }
 
+  /**
+   * Test for HBASE-8794. Avoid NullPointerException in DependentColumnFilter.toString().
+   */
+  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"));
+  }
+
+  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"));
+  }
+
   @org.junit.Rule
   public org.apache.hadoop.hbase.ResourceCheckerJUnitRule cu =
     new org.apache.hadoop.hbase.ResourceCheckerJUnitRule();



Mime
View raw message