Unnecessery null check ActionDistributor.expire()
Brought to you by:
niallg
In org.simpleframework.transport.ActionDistributor:
private void expire(SelectionKey key, long time) throws IOException {
Action task = (Action)key.attachment();
if(task != null) {
long expiry = task.getExpiry();
if(expiry < time) {
expire(key, task); // this call will check key == null
}
}
}
private void expire(SelectionKey key, Action action) throws IOException {
Action cancel = new CancelAction(action);
if(key != null) { // not useful null check
key.attach(cancel);
key.cancel();
}
process(key); // if key == null this call will throw a NullPointerException
}
private void process(SelectionKey key) throws IOException {
Runnable task = (Runnable)key.attachment(); // NullPointerException if key is null
...
In case of a null key, the code would first throw the NPE while trying to retrieve the task from the key's attachement: on the first line of the #expire(SelectionKey,long) method