fix NPE on invalid CQL DELETE command

patch by dbrosius; reviewed by slebresne for CASSANDRA-3755
This commit is contained in:
Sylvain Lebresne 2012-03-29 16:26:53 +02:00
parent 281af5e4f7
commit b0dfb4cdc4
2 changed files with 5 additions and 3 deletions

View File

@ -13,6 +13,7 @@
* fix race leading to super columns assertion failure (CASSANDRA-3957)
* ensure that directory is selected for compaction for user-defined
tasks and upgradesstables (CASSANDRA-3985)
* fix NPE on invalid CQL delete command (CASSANDRA-3755)
1.0.8

View File

@ -74,6 +74,8 @@ public class DeleteStatement extends AbstractModification
/** {@inheritDoc} */
public List<IMutation> prepareRowMutations(String keyspace, ClientState clientState, Long timestamp) throws InvalidRequestException
{
CFMetaData metadata = validateColumnFamily(keyspace, columnFamily);
clientState.hasColumnFamilyAccess(columnFamily, Permission.WRITE);
AbstractType<?> keyType = Schema.instance.getCFMetaData(keyspace, columnFamily).getKeyValidator();
@ -81,18 +83,17 @@ public class DeleteStatement extends AbstractModification
for (Term key : keys)
{
rowMutations.add(mutationForKey(key.getByteBuffer(keyType), keyspace, timestamp, clientState));
rowMutations.add(mutationForKey(key.getByteBuffer(keyType), keyspace, timestamp, clientState, metadata));
}
return rowMutations;
}
/** {@inheritDoc} */
public RowMutation mutationForKey(ByteBuffer key, String keyspace, Long timestamp, ClientState clientState) throws InvalidRequestException
public RowMutation mutationForKey(ByteBuffer key, String keyspace, Long timestamp, ClientState clientState, CFMetaData metadata) throws InvalidRequestException
{
RowMutation rm = new RowMutation(keyspace, key);
CFMetaData metadata = validateColumnFamily(keyspace, columnFamily);
QueryProcessor.validateKeyAlias(metadata, keyName);
AbstractType comparator = metadata.getComparatorFor(null);