Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 356549

Summary: NullPointerException in SessionSingletonBase.getInstanceLock() on browser reload if UICallBack activated
Product: [RT] RAP Reporter: Timo Rohrberg <timo.rohrberg>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: timo.rohrberg
Version: 1.4   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Demo RAP project to reproduce bug.
none
RAP Plugins' versions overview. none

Description Timo Rohrberg CLA 2011-09-02 02:36:40 EDT
Build Identifier: M20110210-1200

The problem has already been discussed here:
http://www.eclipse.org/forums/index.php/t/238002/

If UICallBack is activated in the beginning of an IEntryPoint implementation and deactivated within a SessionStoreListener "beforeDestroy" event, there is sometimes a NullPointerException in the SessionSingletonBase.getInstanceLock() method. This happens when the application is shutdown triggered by a browser reload. The call to ContextProvider.getSession() returns null in the mentioned method, and the access to its getAttribute() method triggers the NullPointerException.

The error does not occur always, but only every third or fourth application shutdown.

Attached, you find a sample RAP project containing a sample IEntryPoint implementation with which the error can be reproduced.

I am using RAP Runtime 1.4 in an Eclipse Helios 3.6.2 environment. In the attached screenshot you can see the exact versions of the used plug-ins.

Reproducible: Sometimes

Steps to Reproduce:
Just run the attached demo project several times and watch the console on which the stack trace will be printed if the exception is triggered.
Comment 1 Timo Rohrberg CLA 2011-09-02 02:38:30 EDT
Created attachment 202652 [details]
Demo RAP project to reproduce bug.
Comment 2 Timo Rohrberg CLA 2011-09-02 02:39:33 EDT
Created attachment 202653 [details]
RAP Plugins' versions overview.
Comment 3 Ivan Furnadjiev CLA 2011-09-02 03:10:05 EDT
Timo, could you post the NPE stack trace?
Comment 4 Timo Rohrberg CLA 2011-09-02 03:57:47 EDT
(In reply to comment #3)
> Timo, could you post the NPE stack trace?

Yes, of course. Sorry, I forgot about this.
Here it is:

java.lang.NullPointerException
at org.eclipse.rwt.SessionSingletonBase.getInstanceLock(SessionSingletonBase.java:106)
at org.eclipse.rwt.SessionSingletonBase.getInstance(SessionSingletonBase.java:88)
at org.eclipse.rwt.internal.lifecycle.UICallBackServiceHandler$IdManager.getInstance(UICallBackServiceHandler.java:53)
at org.eclipse.rwt.internal.lifecycle.UICallBackServiceHandler.isUICallBackActive(UICallBackServiceHandler.java:170)
at org.eclipse.rwt.internal.lifecycle.UICallBackServiceHandler.jsUICallBack(UICallBackServiceHandler.java:149)
at org.eclipse.rwt.internal.lifecycle.UICallBackServiceHandler.writeResponse(UICallBackServiceHandler.java:143)
at org.eclipse.rwt.internal.lifecycle.UICallBackServiceHandler.service(UICallBackServiceHandler.java:91)
at org.eclipse.rwt.internal.service.ServiceManager$HandlerDispatcher.service(ServiceManager.java:33)
at org.eclipse.rwt.internal.engine.RWTDelegate.doPost(RWTDelegate.java:46)
at org.eclipse.rwt.internal.engine.RWTDelegate.doGet(RWTDelegate.java:35)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:126)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:60)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.eclipse.equinox.http.jetty.internal.HttpServerManager$InternalHttpServiceServlet.service(HttpServerManager.java:317)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:924)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Comment 5 Rüdiger Herrmann CLA 2011-09-16 06:25:27 EDT
Timo, 
why do you attempt to deactivate the UICallback at session shutdown in the first place? If the session is terminated, the UICallback is released anyway.
In 1.5, we reworked the UI Callback code (bug 344989, bug 351961) and the code for session singleton management (bug 345702).  Can you reproduce the issue with 1.5?
Comment 6 Timo Rohrberg CLA 2011-09-16 08:03:25 EDT
Hello Rüdiger,

in fact, the problem seems to be solved with the 1.5 nightly build RAP target components - at least, I could not reproduce the bug with it...

Should I close the issue then?

Concerning the UICallBack deactivation: Is it really correct to not deactivate it at all and just leave that to the shutdown of the session? Maybe we should relocate a discussion about this back into my original forum entry (http://www.eclipse.org/forums/index.php/t/238002/)?

Greetings,
Timo
Comment 7 Rüdiger Herrmann CLA 2011-09-16 10:09:51 EDT
(In reply to comment #6)
> in fact, the problem seems to be solved with the 1.5 nightly build RAP target
> components - at least, I could not reproduce the bug with it...
> Should I close the issue then?
Closing as WONTFIX for 1.4, works in 1.5

> Concerning the UICallBack deactivation: Is it really correct to not deactivate
> it at all and just leave that to the shutdown of the session? Maybe we should
> relocate a discussion about this back into my original forum entry
> (http://www.eclipse.org/forums/index.php/t/238002/)?
I added a note to the JavaDoc of UICallBack#activate() and to the server push wiki (http://wiki.eclipse.org/RAP/UI_Callback). Fell free to reference these in the foum if you like.