Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
2.1.9, 2.1.10
-
None
-
Urgent
Description
I've just had a production server lock up, and when I forced a stack trace I saw lots of these:
"TP-Processor30" daemon prio=5 tid=0x00ce2a50 nid=0x52 runnable [bccfd000..bccffc30]
at java.util.HashMap.get(HashMap.java:325)
at org.apache.cocoon.reading.ResourceReader.getLastModified(ResourceReader.java:238)
at org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.process(AbstractProcessingPipeline.java:468)
at org.apache.cocoon.components.treeprocessor.sitemap.ReadNode.invoke(ReadNode.java:84)
etc.
What I've noticed is that the 'documents' HashMap in ResourceReader (a static member) is accessed in an unsynchronized fashion; neither is documents synchronized, or are the puts and gets to it. This is a potential (and actual!!) hazard, and can lead to crashes or hangs.
Suggest that line 94 of ResourceReader.java is changed from:
private static final Map documents = new HashMap();
to
private static final Map documents = Collections.synchronizedMap(new HashMap());
Work-around:
enable quick-modified-test in configuration which by-passes use of the document URI cache:
<map:reader logger="sitemap.reader.resource" name="resource" pool-max="32" src="org.apache.cocoon.reading.ResourceReader">
<quick-modified-test>true</quick-modified-test>
</map:reader>
"TP-Processor30" daemon prio=5 tid=0x00ce2a50 nid=0x52 runnable [bccfd000..bccffc30]
at java.util.HashMap.get(HashMap.java:325)
at org.apache.cocoon.reading.ResourceReader.getLastModified(ResourceReader.java:238)
at org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.process(AbstractProcessingPipeline.java:468)
at org.apache.cocoon.components.treeprocessor.sitemap.ReadNode.invoke(ReadNode.java:84)
etc.
What I've noticed is that the 'documents' HashMap in ResourceReader (a static member) is accessed in an unsynchronized fashion; neither is documents synchronized, or are the puts and gets to it. This is a potential (and actual!!) hazard, and can lead to crashes or hangs.
Suggest that line 94 of ResourceReader.java is changed from:
private static final Map documents = new HashMap();
to
private static final Map documents = Collections.synchronizedMap(new HashMap());
Work-around:
enable quick-modified-test in configuration which by-passes use of the document URI cache:
<map:reader logger="sitemap.reader.resource" name="resource" pool-max="32" src="org.apache.cocoon.reading.ResourceReader">
<quick-modified-test>true</quick-modified-test>
</map:reader>