NullPointerException (NPE) with AsyncClient

com.aerospike.client.AerospikeException: java.lang.NullPointerException
        at com.aerospike.client.async.SelectorManager.registerCommands(SelectorManager.java:131) [ssp.jar:na]
        at com.aerospike.client.async.SelectorManager.runCommands(SelectorManager.java:84) [ssp.jar:na]
        at com.aerospike.client.async.SelectorManager.run(SelectorManager.java:68) [ssp.jar:na]
Caused by: java.lang.NullPointerException: null

Exception happens may be couple of time per hour. Looks like error need to be clarified. No additional stack trace in logs.

We have the same issue, with Client version 3.1.3.

The stack trace is generated from this command:

  command.retryAfterInit(new AerospikeException(e));

The important stack trace is located in the inner exception. Can you modify your code to print this extra stack trace and let us know the results?

  public void onFailure(AerospikeException e) {
    e.printStackTrace();
				
    Throwable cause = e.getCause();
				
    if (cause != null) {	
      System.out.println("Caused by:");
      cause.printStackTrace();
    }
}
com.aerospike.client.AerospikeException: java.lang.NullPointerException
	at com.aerospike.client.async.SelectorManager.registerCommands(SelectorManager.java:131)
	at com.aerospike.client.async.SelectorManager.runCommands(SelectorManager.java:84)
	at com.aerospike.client.async.SelectorManager.run(SelectorManager.java:68)
Caused by: java.lang.NullPointerException
	at com.aerospike.client.async.AsyncConnection.interestOps(AsyncConnection.java:163)
	at com.aerospike.client.async.AsyncCommand.checkTimeout(AsyncCommand.java:237)
	at com.aerospike.client.async.SelectorManager.registerCommands(SelectorManager.java:121)
	... 2 more

Hope this helps.

Thanks, that identified the problem. The command timed out before the SelectionKey was even registered, resulting in a NullPointerException. It’s relatively benign because the command was failing anyhow from a timeout.

We will fix this in the next release.

-Brian