Mantis - Resin
Viewing Issue Advanced Details
1402 major always 10-11-06 04:03 01-04-07 12:03
slonopotamus  
ferg  
normal  
closed 3.0.22  
fixed  
none    
none 3.1.1  
0001402: valueBound should not be invoked when session is read from persistent store
Java Servlet Specification Version 2.4
SRV.15.1.7 HttpSession
=====
When an application stores an object in or removes an object from a session, the
session checks whether the object implements HttpSessionBindingListener .
If it does, the servlet notifies the object that it has been bound to or unbound from
the session. Notifications are sent after the binding methods complete. For session
that are invalidated or expire, notifications are sent after the session has been
invalidated or expired.
=====

But Resin notifies the object when it is read from persistent store.

I suppose the same applies to HttpSessionAttributeListener because reading from persistent store invokes HttpSession#setAttribute.

Notes
(0001541)
slonopotamus   
10-11-06 05:16   
Workaround:

  private static boolean haveResinBug1402 () {
    for (final StackTraceElement element : Thread.currentThread ().getStackTrace ()) {
      if (element.getMethodName ().equals ("load") && element.getClassName ().equals ("com.caucho.server.session.SessionImpl")) {
        return true;
      }
    }
    return false;
  }

  public void valueBound (final HttpSessionBindingEvent event) {
    if (!haveResinBug1402 ()) {
      ...
    }
  }
  public void valueUnbound (final HttpSessionBindingEvent event) {
    if (!haveResinBug1402 ()) {
      ...
    }
  }
(0001542)
slonopotamus   
10-12-06 07:36   
Oops, Resin version is 3.0.21
(0001701)
ferg   
01-04-07 12:03   
server/015o