[
https://issues.apache.org/jira/browse/HBASE-10600?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13911835#comment-13911835
]
Andrew Purtell commented on HBASE-10600:
----------------------------------------
This change isn't good if the List<? extends Row> passed in is implemented with
a linked list:
{code}
Index:
hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncProcess.java
===================================================================
--- hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncProcess.java
(revision 1571444)
+++ hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncProcess.java
(working copy)
@@ -479,7 +479,14 @@
// The position will be used by the processBatch to match the object array
returned.
int posInList = -1;
NonceGenerator ng = this.hConnection.getNonceGenerator();
- for (Row r : rows) {
+ for (int i = 0; i < rows.size(); i++) {
+ Row r = rows.get(i);
+ if (r instanceof Put) {
+ Put put = (Put) r;
+ if (put.isEmpty()) {
+ throw new IllegalArgumentException("No columns to insert for #" +
(i+1) + " item");
+ }
+ }
posInList++;
Action<Row> action = new Action<Row>(r, posInList);
setNonce(ng, r, action);
{code}
I don't think we can assume to receive ArrayList because the type signature
allows all list types. I haven't checked the JRE source but I'd guess that for
example LinkedList#get(pos) will walk from the list head at each loop iteration.
> HTable#batch() should perform validation on empty Put
> -----------------------------------------------------
>
> Key: HBASE-10600
> URL: https://issues.apache.org/jira/browse/HBASE-10600
> Project: HBase
> Issue Type: Bug
> Reporter: Ted Yu
> Assignee: Ted Yu
> Priority: Trivial
> Attachments: 10600-v1.txt, 10600-v2.txt
>
>
> Raised by java8964 in this thread:
> http://osdir.com/ml/general/2014-02/msg44384.html
> When an empty Put is passed in the List to HTable#batch(), there is no
> validation performed whereas IllegalArgumentException would have been thrown
> if this empty Put in the simple Put API call.
> Validation on empty Put should be carried out in HTable#batch().
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)