Community
Participate
Working Groups
Build Identifier: 7.3.1 When the HashSessionManager deIdles sessions, the attributeAdded method of a HttpSessionAttributeListener is called, but the attributeRemoved method is not called during idling. If you're relying on this to say keep a list of active sessions, you might get confused. Is this a bug or is it supposed to work that way? It would seem to me that the attributeAdded method should probably not be invoked at all during deIdling... Reproducible: Always Steps to Reproduce: 1. enable idling in the HashSessionManager 2. when a session is deIdled, attributeAdded will be invoked on your HttpSessionAttributeListener without a corresponding attributeRemoved 3.
Unfortunately there is no clear spec on what should happen. But we should at least try to be symmetric. I'll look for 7.4.1
The workaround is to make the attributeAdded listener idempotent, but its obviously non-intuitive behavior. I would suggest that the expected behavior is that attributeAdded would NOT be called during deIdling, analogous to the way in which the constructor and set methods of a serializable class are not called during deserialization.
I have fixed this by making an idle call unbind and attributeRemoved listeners. This is what is done on a shutdown, so it is pretty similar and any bean that wants to release resources from such a callback needs to know.