cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joerg Heinicke <joerg.heini...@gmx.de>
Subject [IMP] synchronization on session object in Cocoon
Date Tue, 10 May 2005 16:56:01 GMT
Hello,

I think I have found a more general problem with synchronization in Cocoon. I
tried to solve my problem with synchronization in flow script with an
intermediate object. This object handles the synchronized instantiation of my
component. Unfortunately I found out that "synchronized (session) { ... }" still
did not work - two requests of the same session run into that block at the same
time. I did some remote debugging. First I thought the reason is in flow script
as it also wraps the session, but it unwraps it later. The reason is in
HttpRequest class. Have a look at the code [1]:

public Session getSession(boolean create) {
    javax.servlet.http.HttpSession serverSession = this.req.getSession(create);
    if ( null != serverSession) {
        if ( null != this.session ) {
            if ( this.session.wrappedSession != serverSession ) {
                // update wrapper
                this.session.wrappedSession = serverSession;
            }
        } else {
            // new wrapper
            this.session = new HttpSession( serverSession );
        }
    } else {
        // invalidate
        this.session = null;
    }
    return this.session;
}

As you can see on every request a new wrapper is instantiated which is really
bad. It is not possible to synchronize on Cocoon session objects. What we
probably need is a Map mapping the server sessions to the wrapper objects.

WDYT?

Joerg

[1] http://svn.apache.org/viewcvs.cgi/cocoon/tags/RELEASE_2_1_7/src/java/org/
apache/cocoon/environment/http/HttpRequest.java?rev=158761&view=markup


Mime
View raw message