1) on any specific node, request.getSession() returns a different object for each request. The sessionId() remains the same, but the actual object ID changes. This implies that it is a different representation of the session object.Undertow returns a different facade for each request. Undertow uses its internal representation of a session (io.undertow.server.session.Session) that is stored in the session manager, and wraps a facade around it (io.undertow.servlet.spec. HttpSessionImpl) that implements Servlet semantics.
2) if I persist a local copy of the HttpSession object between requests (ex: in a static map) and invalidate the session using the persisted object, my request.getSession() object is not updated (ex: the invalid flag is still set to false), but the session is dead. Trying to call request.getSession().invalidate() throws IllegalStateException as do calls to request.getSession().set/getAt tribute() I guess this could be considered a bug in that isNew will not throw an IllegalStateException, which is the only place that the invalid flag is used without also consulting the underlying session, but you sound as if you expect the session to still work after it has been invalidated?
Request 1:// store a copy of the session object to be available in a later requeststatic Session cachedSessionObj = request.getSession();Request 2:// invalidate the session from the cached objectcachedSessoinObject.invalidate();// get a new sessionSession newSession = request.getSession();
There is no requirement that the same session is represented by a single java object, and especially it in a distributed environment this is not possible. Even though we could keep the same facade around for all requests this can encourage people to write apps that rely on this behaviour, and also increases the likelihood that the facade will become tenured and require a full GC to be reclaimed.
3) over time, my JVM will actually crash with an EXCEPTION_ACCESS_VIOLATION in a GC process. This always seems to correlate with a thread that is trying to do some session invalidation via the persisted session copy.This is a JVM bug. Which JVM are you using?
To implement this I would remove the WeakReference which will not work with Undertow's session management strategy, and instead register a listener to remove the session from the local map when it is invalidated. If you really want to access the underlying Undertow session you can call io.undertow.servlet.spec.HttpSessionImpl#getSession() to return the Underlying Undertow session, although it should not be necessary.
Is anyone able to explain this behaviour? Why is the session object always different between requests? Shouldn't it be the same request? What is Undertow doing with the session objects between requests? Is the Undertow object being passivated in some way and my attempt to invalidate if from within my cached version causing this kind of access violation? Is my cached object referencing memory that has been cleared by the GC (ex: does the request.getSession() object only a WeakReference to the actual Undertow object)?Finally, what would the recommended approach be to doing something like this? Using a distributed web-cache is unfortunately not an option at the moment. So give that, is there some way to access the Undertow session manager directly?Thanks for any insight. I thought we had a functional solution but in production (under real load), the intermittent JVM crashes are telling me that our solution is broken.Eric
_______________________________________________
wildfly-dev mailing list
wildfly-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/wildfly-dev