Details
-
Bug
-
Status: Resolved
-
Resolution: Fixed
-
2.6
-
None
-
None
-
Operating System: All
Platform: PC
Description
If an Image in org/apache/xmlgraphics/image/loader/cache/ImageCache.java expires a ConcurrentModificationException will be thrown.
The cause is method "private void doInvalidURIHouseKeeping()" which loops over the Map "this.invalidURIs" and then tries to remove an element from this map in method "private boolean removeInvalidURIIfExpired(String uri, long timestamp)".
To reproduce the error you can add the following method to ImageCacheTestCase.
public void testImageCacheHouseKeeping() {
ImageCache imageCache = new ImageCache(new TimeStampProvider(), new DefaultExpirationPolicy(1));
imageCache.registerInvalidURI("invalid");
imageCache.registerInvalidURI("invalid2");
try
catch (InterruptedException e)
{ e.printStackTrace(); } imageCache.doHouseKeeping();
}
Stacktrace:
Caused by: java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:793)
at java.util.HashMap$EntryIterator.next(HashMap.java:834)
at java.util.HashMap$EntryIterator.next(HashMap.java:832)
at org.apache.xmlgraphics.image.loader.cache.ImageCache.doInvalidURIHouseKeeping(ImageCache.java:294)
at org.apache.xmlgraphics.image.loader.cache.ImageCache.doHouseKeeping(ImageCache.java:287)
at org.apache.xmlgraphics.image.loader.cache.ImageCache.considerHouseKeeping(ImageCache.java:277)
at org.apache.xmlgraphics.image.loader.cache.ImageCache.registerInvalidURI(ImageCache.java:206)
at org.apache.xmlgraphics.image.loader.cache.ImageCache.needImageInfo(ImageCache.java:129)
at org.apache.xmlgraphics.image.loader.ImageManager.getImageInfo(ImageManager.java:112)
at org.apache.fop.fo.flow.ExternalGraphic.bind(ExternalGraphic.java:81)
at org.apache.fop.fo.FObj.processNode(FObj.java:123)
at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:282)
at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:171)
at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1072)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
at org.apache.xerces.xinclude.XIncludeHandler.emptyElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:484)