Joerg Heinicke wrote > Bug was fixed some days ago: > http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14348. Carsten > requested for testers of the patch, so if you can test the behaviour > with the current Cocoon 2.0 CVS it will be good. > > If XSP is the result of a pipeline then the ServerPages Generator can't > > work out its currency and randomly re-generates and compiles. To make > > I have inspected the code of 2.0.4 and it is still there, ie code is > > same as when reported in 2001. Surely a typical use of cocoon is to > > build XSP using XSLT?
I have tested (with cocoon-2.0_20030812221701) and believe the problem has only been partially solved. Instead of the prior situation where the .java & .class were re-generated from XSP on a random basis - they now are always regenerated. This is at least consistent - but very wasteful on resources & latency in requests. I have investigated the source and found that the test as to whether or not regeneration takes place is: !currValidity.equals(prevValidity) Inspecting the contents of the currValidity and prevValidity Maps I find that they are equivalent excepting that the prevValidity contains an entry "S-xml-1_=NOP Validity" so the test fails and code is re-generated. However, it appears that the "NOP Validity" is simply indicating an always valid condition - so code should not be re-generated. I have added some code to strip the NOPCacheValidity entries and do a comparison and my problem is solved - ie code is only regenerated when the cached objects are out-of-date. I have pasted the diff of my patch at the end of this message. I think the bug http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14348 should be re-opened. Your views Joerg , Carsten? John Williams Suggested patch to SiteMapSource.java: @@ -56,12 +56,15 @@ import java.io.InputStream; import java.net.MalformedURLException; import java.util.Map; +import java.util.HashMap; +import java.util.Iterator; import org.apache.avalon.framework.component.ComponentException; import org.apache.avalon.framework.component.ComponentManager; import org.apache.cocoon.ProcessingException; import org.apache.cocoon.Processor; import org.apache.cocoon.caching.PipelineCacheKey; +import org.apache.cocoon.caching.NOPCacheValidity; import org.apache.cocoon.components.CocoonComponentManager; import org.apache.cocoon.components.EnvironmentStack; import org.apache.cocoon.components.pipeline.CacheableEventPipeline; @@ -322,7 +325,7 @@ Map currValidity = cep.generateValidity(this.environment); - if (prevValidity == null || !currValidity.equals(prevValidity)) { + if (prevValidity == null || !equalsIgnoreNOPCacheValidities(currValidity, prevValidity)) { // validity changed, update cached validity, timestamp and last modified this.lastModificationDate = System.currentTimeMillis(); obj = new Object[] {new Long (this.lastModificationDate), currValidity}; @@ -365,6 +368,29 @@ this.needsRefresh = false; } + static boolean equalsIgnoreNOPCacheValidities (Map aMapWithNOPValidities, Map anotherMapWithNOPValidities) { + return stripNOPValidities(aMapWithNOPValidities).toString().equals(stripNOPValiditi es(anotherMapWithNOPValidities).toString()); + } + + + static Map stripNOPValidities(Map withNOPValidities) { + if (withNOPValidities == null) return null; + else { + if (withNOPValidities.containsValue(NOPCacheValidity.CACHE_VALIDITY)) { + Map retVal = new HashMap(); + Iterator iter = withNOPValidities.entrySet().iterator(); + for (; iter.hasNext(); ) { + Map.Entry entry = (Map.Entry)iter.next(); + if (!entry.getValue().equals(NOPCacheValidity.CACHE_VALIDITY)) + retVal.put(entry.getKey(), entry.getValue()); + } + return retVal; + } + else return withNOPValidities; + } + } + + /** * Return a new <code>InputSource</code> object */