It suddenly dawned on me that the code below is synchronizing on the session, not a local object. Duh! Still, this seems like a very, very bad idea to me, as I'm not sure how that would impact the servlet container.

public Session getSession(boolean create) {
   // we must assure a 1:1-mapping of server session to cocoon session
   javax.servlet.http.HttpSession serverSession = this.req.getSession(create);
   if (serverSession != null) {
       synchronized (serverSession) {
           // retrieve existing wrapper
           this.session =
(HttpSession)serverSession.getAttribute(HTTP_SESSION);
           if (this.session == null) {
               // create wrapper
               this.session = new HttpSession(serverSession);
               serverSession.setAttribute(HTTP_SESSION, this.session);
           }
       }
   } else {
       // invalidate
       this.session = null;
   }
   return this.session;
}














Reply via email to