Skip to content

30 sec puzzle: spot the null pointer

by aloshbennett on October 23rd, 2011

I got a null pointer exception at the line mentioned. What could have caused it?

private ARTTimerTask timerTask = ARTTimerTask.getInstance();
...
public void notify(String messageId, Long messageTime) {
    ...
    //NPE in the line below
    timerTask.addMessage(messageId,
                  System.currentTimeMillis() - messageTime);
}

Here’s the relevant section from ARTTimerTask:

private static final ARTTimerTask _INSTANCE 
                                = new ARTTimerTask();
 
public static ARTTimerTask getInstance() {
    return _INSTANCE;
}

(Debashish comes over to the desk, takes a look and proclaims, “This A*** B***** is pathetic”. 7 seconds!)

From → java

2 Comments
  1. Not able to find yet :(
    Code Looks OK to me !!

  2. I did get an NPE there :)

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS