cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 33836] New: - JXTemplateGenerator cache thread safety problem
Date Thu, 03 Mar 2005 21:31:47 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=33836>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=33836

           Summary: JXTemplateGenerator cache thread safety problem
           Product: Cocoon 2
           Version: 2.1.6
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: sitemap components
        AssignedTo: dev@cocoon.apache.org
        ReportedBy: niklas@trillian.se


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.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

Mime
View raw message