Tuesday, September 17, 2013

Cassandra: InvalidRequestException(why:Key may not be empty)

When you get this exception when you try to submit some changes through the THRIFT gateway to the cluster,

the code are simple,
  

client.remove(KEYSPACE, key,cp, System.currentTimeMillis(), ConsistencyLevel.ALL);

and when you check the key==null, it’s not null for sure, but how comes still get the key empty error?

then check ThriftValidation class,
image

now you know, the key is not null, the remaning() is zeor.
typically this means the key itself has been read and the pointer is at the end, so before you read the key, try duplicate a new one.

use this utilit lib instead, http://svn.apache.org/repos/asf/cassandra/trunk/src/java/org/apache/cassandra/utils/ByteBufferUtil.java

No comments:

 
Locations of visitors to this page