HBASE-10600 HTable#batch() should perform validation on empty Put
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1571899 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
31b8b2d92b
commit
d77ef9a8b5
|
@ -481,6 +481,12 @@ class AsyncProcess {
|
||||||
NonceGenerator ng = this.hConnection.getNonceGenerator();
|
NonceGenerator ng = this.hConnection.getNonceGenerator();
|
||||||
for (Row r : rows) {
|
for (Row r : rows) {
|
||||||
posInList++;
|
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);
|
Action<Row> action = new Action<Row>(r, posInList);
|
||||||
setNonce(ng, r, action);
|
setNonce(ng, r, action);
|
||||||
actions.add(action);
|
actions.add(action);
|
||||||
|
|
|
@ -267,6 +267,30 @@ public class TestFromClientSide3 {
|
||||||
"hbase.hstore.compaction.min"));
|
"hbase.hstore.compaction.min"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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
|
@Test
|
||||||
public void testHTableExistsMethodSingleRegionSingleGet() throws Exception {
|
public void testHTableExistsMethodSingleRegionSingleGet() throws Exception {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue