Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Tracking down invalidated session

if your sessionList.get() call and sessionList.remove() call are on different threads you might just be hitting some standard concurrency issues.

In other words, imagine this order of events with 2 threads:

T1 - sessionList.get()
T2 - sessionList.remove()
T1 - session.getAttribute()



--
Joakim Erdfelt <joakim@xxxxxxxxxxx>
Expert advice, services and support from from the Jetty & CometD experts


On Tue, Feb 18, 2014 at 9:26 AM, John English <john.foreign@xxxxxxxxx> wrote:
I'm trying to track down a weird error relating to sessions. Using Jetty 8.1.8, I'm getting an IllegalStateException when I try to use getAttribute() to get an attribute from a session, which apparently indicates that the session has been invalidated.

When a session is created, I store a reference to it in an ArrayList, so that I can display a list of logged-in users with code like this:

  HttpSession session = sessionList.get(n);
  SessionState s = (SessionState)session.getAttribute("state");
  ...                                    ^^^^^^^^^^^^ IllegalStateException!

and I have a session listener which removes sessions from the list when they are destroyed:

  public void sessionDestroyed(HttpSessionEvent event) {
    HttpSession session = event.getSession();
    sessionList.remove(session);
    ...
  }

This is hard for me to figure out since it happened on a live system and I can't reproduce it elsewhere, and I can't get at the sessionList on the live system. It just happened the other day for the first time following an update a couple of weeks ago, so there's obviously something in the updated code which has caused it, but working through the changelogs I can't see anything remotely relevant -- this is all old code.

It looks like the session is being invalidated without sessionDestroyed() being called -- is there any way that could happen? Or is there any other reason for an IllegalStateException to be thrown?

TIA,
--
John English
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-users


Back to the top