Nathaniel Alfred <Alfred.Nathaniel <at> swx.com> writes: > AFAIKS is the purpose of the existing synchronized(session) bits to > protect the consistency of the session object in case it is shared > between parallel executing requests.
Yes. > IIUC you need a lock object to really synchronize parallel requests. > There I'd say the session is the wrong candidate due to the mentioned > possible dependency on the servlet That's where you and I have different interpretations. The sentence you quoted is IMO only about information hiding between different web applications. It does not say anything about if it is guaranteed to have exactly one session object or not. Another sentence is the following [1]: "The servlet container uses *this interface* to create *a session* between an HTTP client and an HTTP server. The *session persists* for a specified time period, *across more than one connection or page request from the user*." IMO this means _session_ is not only an abstract real world object, but a Java object. And you can access the same session object on different requests of the same (here "real world") session. > I am just afraid that keeping the wrapped sessions in a private map > may introduce a memory leak. But maybe WeakHashMap would take care > of this... Yes, see Sylvain's proposal or my other mail. Joerg [1] http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet/http/ HttpSession.html
