Hi,
Switching from 9.3 to 9.4, I'm a bit confused about the default behaviours about sessions.
We are using Jetty as embedded server, very simply using an HandlerList with some SessionHandler subclasses.
On previous versions of Jetty, to be able to use sessions in our case,
we just shared the session manager like that :
final SessionManager sessionManager = new HashSessionManager();
for (Handler handler : handlerList) {
if (handler instanceof SessionHandler) {
((SessionHandler) handler).setSessionManager(sessionManager);
}
}
And used a
HashSessionIdManager like this :
server.setSessionIdManager(
new HashSessionIdManager()
);
Even if I never understood why the session manager was not common by default,
after reading the 9.4 documentation, it's clear that the new system is a clean approach.
But I see no easy way to share the SessionCache.
I tried a naive approach:
final SessionIdManager sessionManager = new DefaultSessionIdManager(server);
server.setSessionIdManager(sessionManager);
final SessionCache cache = firstHandler.getSessionCache();
for (Handler handler : h.getHandlers()) {
if (handler instanceof SessionHandler) {
final SessionHandler sessionHandler = (SessionHandler) handler;
((SessionHandler) handler).setSessionCache(cache);
sessionHandler.setSessionIdManager(sessionManager);
}
}
But a Session created from a handler is not shared with an other handler.
I wonder why it's not by default, and would be happy to know how this kind behaviour
could be configured. I bet I missed a key point.
Regards,
Guillaume