Fix IndexOutOfBoundsException when using empty BATCH statements

patch by Vovodroid; reviewed by Benjamin Lerer for CASSANDRA-10277
This commit is contained in:
Vovodroid 2015-09-17 20:57:51 +02:00 committed by blerer
parent b62fde1bb7
commit 1a2a1d2c24
2 changed files with 7 additions and 1 deletions

View File

@ -510,7 +510,7 @@ public class BatchStatement implements CQLStatement
// Use the CFMetadata of the first statement for partition key bind indexes. If the statements affect
// multiple tables, we won't send partition key bind indexes.
Short[] partitionKeyBindIndexes = haveMultipleCFs ? null
Short[] partitionKeyBindIndexes = (haveMultipleCFs || batchStatement.statements.isEmpty())? null
: boundNames.getPartitionKeyBindIndexes(batchStatement.statements.get(0).cfm);
return new ParsedStatement.Prepared(batchStatement, boundNames, partitionKeyBindIndexes);

View File

@ -103,4 +103,10 @@ public class BatchTest extends CQLTester
row(111, "batchtext", null)
);
}
@Test
public void testBatchEmpty() throws Throwable
{
execute("BEGIN BATCH APPLY BATCH;");
}
}