Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Kill/Shutdown the UIThread from a background thread
Kill/Shutdown the UIThread from a background thread [message #1768533] Wed, 19 July 2017 18:26 Go to next message
MIchael P is currently offline MIchael PFriend
Messages: 3
Registered: March 2017
Junior Member
Hi,

I have a workbench RAP application, which uses the Apache Shiro framework for session management. The problem I have is that when the session gets invalidated and the workbench is still open, the UIthread seems to ignore the fact that the HttpSession is gone, but the display is not marked as "disposed". To make sure everything closes I have a background thread which acts as a heartbeat, but I don't know how to kill the application(UIThread, Workbench). I can, however, kill all daemon threads I started. The only remaining thing is the UIThread.

Is there a way to interrupt the UIThread and make it react to the missing HttpSession?
Can I close the UIThread by force somehow?
Re: Kill/Shutdown the UIThread from a background thread [message #1768549 is a reply to message #1768533] Wed, 19 July 2017 22:12 Go to previous messageGo to next message
Chris Fairhall is currently offline Chris FairhallFriend
Messages: 221
Registered: February 2011
Senior Member
i would raise a bug if the UIThread isn't terminating when the HttpSession is invalidated.
A listener is added to the session so UIThread#terminateThread ends up being called.
Re: Kill/Shutdown the UIThread from a background thread [message #1768671 is a reply to message #1768549] Fri, 21 July 2017 08:27 Go to previous messageGo to next message
MIchael P is currently offline MIchael PFriend
Messages: 3
Registered: March 2017
Junior Member
As I understand an attribute is added to the HttpSession, which acts as a callback when removed from the session. I'm not sure if there is a standard on how the HttpSession must behave, but looking at the Shiro session the attribute is not removed before logging out or invalidating the session. This leads to an invalid HttpSession and a UIThread which is waiting.

As a workaround, I try to call the valueUnbound method of the HttpSessionBindingListener when logging out of the Shiro session.
This is done with the onLogout method of the realm and looks like this

@Override                                                                                             
public void onLogout(PrincipalCollection principals) {                                                
    super.onLogout(principals);                                                                       
    Collection<Object> list = SecurityUtils.getSubject().getSession(false).getAttributeKeys();                                                                                     
    for (Iterator<Object> it = list.iterator(); it.hasNext();) {                                      
        Object key = it.next();                                                                       
        if (key instanceof String) {                                                                  
            String skey = (String) key;                                                               
            if (skey.contains("UISession")) {                                                         
                Object callback = SecurityUtils.getSubject().getSession(false).getAttribute(key);     
                if (callback instanceof HttpSessionBindingListener) {                                 
                    HttpSessionBindingListener listener = (HttpSessionBindingListener) callback;      
                    listener.valueUnbound(null);                                                      
                }                                                                                     
            }                                                                                         
        }                                                                                             
    }                                                                                                 
}


I hope I don't mess something up with this approach, but I think it should behave the same as calling shutdown on UISessionImpl.

[Updated on: Fri, 21 July 2017 08:34]

Report message to a moderator

Re: Kill/Shutdown the UIThread from a background thread [message #1768714 is a reply to message #1768671] Sat, 22 July 2017 03:45 Go to previous message
Chris Fairhall is currently offline Chris FairhallFriend
Messages: 221
Registered: February 2011
Senior Member
If Apache Shiro isn't calling the HttpSessionBindingListener#valueUnbound when the session is invalidated, it's a defect in Apache Shiro.

Manually calling the method isn't going to work when the container expires the session due to inactivity.
Previous Topic:RAP and mobile hiding keyboard does not reappear when entering text widget
Next Topic:[solved] Immediate Session Timeout when OperationMode=SESSION_FAILOVER
Goto Forum:
  


Current Time: Thu Apr 18 13:42:29 GMT 2024

Powered by FUDForum. Page generated in 0.02081 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top