cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niklas Therning <nik...@trillian.se>
Subject Bug in JXTemplateGenerator
Date Thu, 03 Mar 2005 17:10:02 GMT
Hi,

I just upgraded to 2.1.6 and found a bug in JXTemplateGenerator.

The bug appears if one thread calls setup() and removes the cached 
template from the cache. Before it has been able to reparse the template 
and put it back into the cache another thread executes generate() and 
asks the cache for the same template. The second thread will get a null 
startEvent.

Here's the relevant part of the setup()-method:

            synchronized (cache) {
                startEvent = (StartDocument)cache.get(uri);
                if (startEvent != null) {
                    int valid = SourceValidity.UNKNOWN;
                    if (startEvent.compileTime != null) {
                        valid = startEvent.compileTime.isValid();
                    }
                    if (valid == SourceValidity.UNKNOWN && 
startEvent.compileTime != null) {
                        SourceValidity validity = inputSource.getValidity();
                        valid = startEvent.compileTime.isValid(validity);
                    }
                    if (valid != SourceValidity.VALID) {
                        cache.remove(uri);
                        regenerate = true;
                    }
                } else {
                    regenerate = true;
                }
            }
            if (regenerate) {
                Parser parser = new Parser();
                SourceUtil.parse(this.manager, this.inputSource, parser);
                startEvent = parser.getStartEvent();
                startEvent.compileTime = this.inputSource.getValidity();
                synchronized (cache) {
                    cache.put(uri, startEvent);
                }
            }

To fix this either put the 'if (regenerate)' block inside the 
synchronized block or remove the 'cache.remove(uri)' line.

Regards,
Niklas Therning


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message