In the application, we use to switch sessions once the user mode is changed.
So basically we have something like this:
request.getSession(false).invalidate();
request.getSession(true);
Now happens the problem: after timeout, the session is not removed. After debugging some internal code, I found out that in org.eclipse.jetty.server.session.AbstractSession.timeout() the session is not removed if _requests > 0. And the _requests is greater then zero, since in org.eclipse.jetty.server.session.SessionHandler.doScope(String, Request, HttpServletRequest, HttpServletResponse) the complete() runs on the access session is increased and the same session is decreased, even if during the invocation the actual session was replaced!
Did anyone experience the same problem and managed to solve it?
Updated: I created a workaround. See accepted answer below.
Updated: Bug in Jersey Community: https://bugs.eclipse.org/bugs/show_bug.cgi?id=377610
I have solved this problem, by overriding the SessionHandler:
In the application’s context: