hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject svn commit: r1571899 - in /hbase/trunk: hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncProcess.java hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide3.java
Date Wed, 26 Feb 2014 02:44:32 GMT
Author: tedyu
Date: Wed Feb 26 02:44:31 2014
New Revision: 1571899

URL: http://svn.apache.org/r1571899
Log:
HBASE-10600 HTable#batch() should perform validation on empty Put


Modified:
    hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncProcess.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide3.java

Modified: hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncProcess.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncProcess.java?rev=1571899&r1=1571898&r2=1571899&view=diff
==============================================================================
--- hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncProcess.java
(original)
+++ hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncProcess.java
Wed Feb 26 02:44:31 2014
@@ -481,6 +481,12 @@ class AsyncProcess {
     NonceGenerator ng = this.hConnection.getNonceGenerator();
     for (Row r : rows) {
       posInList++;
+      if (r instanceof Put) {
+        Put put = (Put) r;
+        if (put.isEmpty()) {
+          throw new IllegalArgumentException("No columns to insert for #" + (posInList+1)+
" item");
+        }
+      }
       Action<Row> action = new Action<Row>(r, posInList);
       setNonce(ng, r, action);
       actions.add(action);

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide3.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide3.java?rev=1571899&r1=1571898&r2=1571899&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide3.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide3.java
Wed Feb 26 02:44:31 2014
@@ -268,6 +268,30 @@ public class TestFromClientSide3 {
   }
 
   @Test
+  public void testHTableBatchWithEmptyPut() throws Exception {
+    HTable table = TEST_UTIL.createTable(
+      Bytes.toBytes("testHTableBatchWithEmptyPut"), new byte[][] { FAMILY });
+    try {
+      List actions = (List) new ArrayList();
+      Object[] results = new Object[2];
+      // create an empty Put
+      Put put1 = new Put(ROW);
+      actions.add(put1);
+      
+      Put put2 = new Put(ANOTHERROW);
+      put2.add(FAMILY, QUALIFIER, VALUE);
+      actions.add(put2);
+      
+      table.batch(actions, results);
+      fail("Empty Put should have failed the batch call");
+    } catch (IllegalArgumentException iae) {
+      
+    } finally {
+      table.close();
+    }
+  }
+  
+  @Test
   public void testHTableExistsMethodSingleRegionSingleGet() throws Exception {
 
     // Test with a single region table.



Mime
View raw message