Atmosphere/atmosphere — pull request #593 by Gekkio (2012-09-03 10:53:34+00:00)
Title: Session timeout works with serialization and multiple requests

This pull request fixes all current session leak issues I've found (#555, #592). It might also fix #407.
My tests were done with Tomcat 7.0.23, and I tracked the session behaviour with psi-probe 2.3.2 while running a simple test app with a single AtmosphereHandler.

There is one place in the code that isn't 100% thread-safe, but the servlet API doesn't provide a good way to deal with that (atomic getAndSetAttribute operation). In order to minimize potential issues, the restorer is never removed from a session. The restorer is internally thread-safe, so issues can only occur if multiple atmosphere requests are started at the exact same time before any restorers have been initialized.

I will do further testing with a real-world application, but I've sent this pull request now because current testing has revealed no flaws in the change.