cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Goers <Ralph.Go...@dslextreme.com>
Subject Re: [IMP] synchronization on session object in Cocoon
Date Thu, 12 May 2005 07:15:01 GMT
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;
}








>
>  
>


Mime
View raw message