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

Bug 351961

Summary: [UICallback] Active UICallback prevents session timeout
Product: [RT] RAP Reporter: Sabine Neubauer <neubauer>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: a.nesheret
Version: 1.4   
Target Milestone: 1.5 M1   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 344989    

Description Sabine Neubauer CLA 2011-07-13 08:29:12 EDT
Build Identifier: 

The following issue is already discussed in the newgsroup: http://www.eclipse.org/forums/index.php/t/219777/ . Because this is really a severe problem, I create this bug although we found a workaround. The description below is copied from the newsgroup post.

In our application (based on RAP 1.4) we need to activate UICallBack globally because we do not know in advance when UI updates are needed because they are triggered by user interactions.

Therefore, we activate the UICallBack in ApplicationWorkbenchAdvisor.postStartup() and add a SessionStoreListener for deactivating it and doing some cleanup.

Snippet:
public void postStartup() {
   UICallBack.activate(RWT.getSessionStore().getId());		
   RWT.getSessionStore().addSessionStoreListener(new SessionStoreListener(){            
            @Override
            public void beforeDestroy(SessionStoreEvent event) {
                UICallBack.deactivate(RWT.getSessionStore().getId());
                System.out.println(RWT.getSessionStore().getId() + ": before destroy");
            }
   });
}

Our observations are the following:
1. Reloading the page
- SessionStoreListener.beforeDestroy is called
- same UIThread is used afterwards
2. Session timeout page
- session timeout page appears
- clicking the link creates a new UIThread
- SessionStoreListener.beforeDestroy is never called and the former UIThread hangs
3. Closing browser/browser tab
- SessionStoreListener.beforeDestroy is never called and the UIThread hangs

After a while there are many hanging UIThreads and the sessions are never disposed. Hence, memory consumption increases with each session and it does not decrease.

Our current workaround is to maintain all created sessions by a singleton with application scope. A background thread validates them periodically (dependent on maxInactiveInterval) and invalidates the underlying HttpSession if the gap between current time and last accessed time is greater than maxInactiveInterval. If a session timeouts independently of our workaround it is removed from the list of maintained sessions. 

Reproducible: Always

Steps to Reproduce:
1. Create a project using the template RAP Application with a view
2. Adapt the postStartup like described above
3. Start the application with a very low time out
4. Observe the session timeouts
Comment 1 Rüdiger Herrmann CLA 2011-07-20 13:20:02 EDT
What servlet engine are you using?
Comment 2 Rüdiger Herrmann CLA 2011-07-20 17:47:15 EDT
My observations regarding how different servlet engines behave when there is a standing callback requests:
* Jetty 6.1.x does not invalidate the session while there is a callback request standing
* Jetty 7.4.x does not invalidate the session while there is a callback request standing
* Tomcat 7.0.12 *does* invalidate the session even though there is a callback request standing
Jetty 7 and Tomcat ran as embedded servlet engines from the cluster test suite [1], so their configuration might slightly differ from the standalone mode.

[1] http://wiki.eclipse.org/RAP/RWT_Cluster#Test_Infrastructure
Comment 3 Sabine Neubauer CLA 2011-07-21 02:25:31 EDT
(In reply to comment #1)
> What servlet engine are you using?
We are using jetty 6.1.23 which is embedded in our application, i.e. we do not deploy our application as war file.

Thanks for your investigations.
Comment 4 Rüdiger Herrmann CLA 2011-07-21 08:39:23 EDT
For each standing callback request it is checked regularly (currently every 30 Seconds) whether the request should be released. These checks were extended to also include the session timeout. If a callback request is held for a longer than the session timeout interval, it is released.
Changes are in CVS HEAD