dacanalr
dacanalr

Reputation: 193

Pelop deleteSubColumns => NullPointerException

This the code :

Selector selector = Pelops.createSelector(CASSANDRA_POOL);
Column column = selector.getSubColumnFromRow("Neighbours", user, neighbour, "Link_ID", CL_ONE);
String linkID = new String(column.getValue());
Mutator mutator = Pelops.createMutator(CASSANDRA_POOL);
System.out.println(linkID);
System.out.println(topic);
mutator.deleteSubColumns("Links",linkID,topic);
mutator.execute(CL_ONE);

and here the result :

ERROR - Exception being returned to browser when processing /ajax_request/F314921638127GLWWRG/: Message: java.lang.NullPointerException
  org.scale7.cassandra.pelops.Validation.validateColumnNames(Validation.java:60)
  org.scale7.cassandra.pelops.Mutator.deleteSubColumns(Mutator.java:724)
  org.scale7.cassandra.pelops.Mutator.deleteSubColumns(Mutator.java:698)

But I can't understand why it gives me the exception, the linkID and topic String have the right values.

PS : the version of cassandra is 1.0.0 and the version of pelops is 1.3-1.0.x-20111021.060203-2

Can someone help me ?

Upvotes: 1

Views: 162

Answers (1)

danw
danw

Reputation: 1558

I can't seem to replicate your issue based on the information provided, however I could replicate by passing null as the as the column name (topic in your example).

I've added a test to MutatorIntegrationTest to verify that test Mutator.deleteSubColumns works as expected and I've also made a minor change to the Validator class to avoid the NullPointerException and instead throw a org.scale7.cassandra.pelops.exceptions.ModelException.

See MutatorIntegrationtest.testDeleteSubColumns() and MutatorIntegrationtest. testDeleteSubColumnsWithNullColumnNameThrowsCorrectException()

So in short; make sure your 'topic' variable is not null and upgrade to the latest Pelops SNAPSHOT (for a better error message).

Upvotes: 2

Related Questions