IDEMPIERE-5049 Zk Session and Desktop object not destroy immediately after logout (#999)

- fix invalidation of session
This commit is contained in:
hengsin 2021-11-23 19:45:49 +08:00 committed by GitHub
parent 4d9faf5fae
commit d37993a992
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 8 deletions

View File

@ -190,10 +190,10 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
final Session session = desktop.getSession();
//clear context, invalidate session
Env.getCtx().clear();
destroySession(session);
desktop.setAttribute(DESKTOP_SESSION_INVALIDATED_ATTR, Boolean.TRUE);
Env.getCtx().clear();
Adempiere.getThreadPoolExecutor().schedule(() -> {
((SessionCtrl)session).invalidateNow();
desktop.setAttribute(DESKTOP_SESSION_INVALIDATED_ATTR, Boolean.TRUE);
try {
desktopCache.removeDesktop(desktop);
} catch (Throwable t) {
@ -415,7 +415,7 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
//clear context, invalidate session
Env.getCtx().clear();
destroySession(session);
afterLogout(session);
desktop.setAttribute(DESKTOP_SESSION_INVALIDATED_ATTR, Boolean.TRUE);
//redirect to login page
@ -429,7 +429,7 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
}
}
private void destroySession(final Session session) {
private void afterLogout(final Session session) {
try {
((SessionCtrl)session).onDestroyed();
} catch (Throwable t) {
@ -443,8 +443,6 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
*/
public void logoutAfterTabDestroyed(){
Desktop desktop = Executions.getCurrent().getDesktop();
if (desktop.isServerPushEnabled())
desktop.enableServerPush(false);
DesktopWatchDog.removeDesktop(desktop);
Session session = logout0();
@ -453,7 +451,7 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
Env.getCtx().clear();
SessionCtrl ctrl = (SessionCtrl) session;
if (!ctrl.isInvalidated() && session.getNativeSession() != null)
destroySession(session);
afterLogout(session);
}