Details
Description
There is a NullPointerException when one attempts to invalidate a session:
request.getSession().invalidate();
The source of the exception is line 374 (in version 7.1.6) of JDBCSessionIdManager.java:
I refactored the code around that line into a more debuggable form:
------------------------------------------------------------------------
Handler[] x = jettyServer.getChildHandlersByClass(ContextHandler.class);
for(int i = 0; x != null && i < x.length; i++)
------------------------------------------------------------------------
Running this code causes a NullPointerException on the indicated line. The code seems to be wrongfully assuming that every ContextHandler has a SessionHandler associated to it. getChildHandlerByClass() presumably returns a NULL if no child handler of the specified class can be found. Predictably, calling getSessionManager() on this NULL pointer causes a run-time exception to be thrown.
I propose to modify the code inside the for() loop:
------------------------------------------------------------------------
SessionHandler handler = ((SessionHandler)((ContextHandler)contexts[i])
.getChildHandlerByClass(SessionHandler.class));
if(handler == null)
{ /* No associated session handler, skip this child handler */ continue; }SessionManager = handler.getSessionManager();
------------------------------------------------------------------------
JIRA seems to have messed up the line breaks. Hopefully the code is still readable.