Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 343936 - HashSessionManager deIdling invokes HttpSessionAttributeListener.attributeAdded without having invoked attributeRemoved
Summary: HashSessionManager deIdling invokes HttpSessionAttributeListener.attributeAdd...
Status: RESOLVED FIXED
Alias: None
Product: Jetty
Classification: RT
Component: server (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 7.2.x   Edit
Assignee: Greg Wilkins CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-27 04:45 EDT by Roger Armstrong CLA
Modified: 2011-05-10 02:37 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Roger Armstrong CLA 2011-04-27 04:45:53 EDT
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.
Comment 1 Greg Wilkins CLA 2011-05-06 02:01:36 EDT
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
Comment 2 Roger Armstrong CLA 2011-05-06 05:27:48 EDT
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.
Comment 3 Greg Wilkins CLA 2011-05-10 02:37:48 EDT
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.