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