Uploaded image for project: 'XMLGraphicsCommons'
  1. XMLGraphicsCommons
  2. XGC-117

ConcurrentModificationException in ImageCache / ImageCache not thread-safe

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.3
    • Fix Version/s: None
    • Component/s: general
    • Labels:
      None

      Description

      When using a single FopFactory to create multiple Fop instances that are used in different threads I get an ConcurrentModificationException in ImageCache#doInvalidURIHouseKeeping in line 294.

       

      Source of the problem is the that new HashSet(this.invalidURIs.keySet()) internaly iterates over the key-set that is backed by the HashMap and when another thread changes the HashMap the ConcurrentModificationException occurs.

       

      In my opinion there must be synchronized-blocks around each access of the invalidURIs map  to solve this problem. The use of a synchronized map can not solve this problem.

       

      Stacktrace:

      Caused by: java.util.ConcurrentModificationException: null
      at java.util.HashMap$HashIterator.nextNode(HashMap.java:1437)
      at java.util.HashMap$KeyIterator.next(HashMap.java:1461)
      at java.util.AbstractCollection.addAll(AbstractCollection.java:343)
      at java.util.HashSet.<init>(HashSet.java:119)
      at org.apache.xmlgraphics.image.loader.cache.ImageCache.doInvalidURIHouseKeeping(ImageCache.java:294)
      at org.apache.xmlgraphics.image.loader.cache.ImageCache.doHouseKeeping(ImageCache.java:290)
      at org.apache.xmlgraphics.image.loader.cache.ImageCache.considerHouseKeeping(ImageCache.java:280)
      at org.apache.xmlgraphics.image.loader.cache.ImageCache.registerInvalidURI(ImageCache.java:209)
      at org.apache.xmlgraphics.image.loader.cache.ImageCache.needImageInfo(ImageCache.java:130)
      at org.apache.xmlgraphics.image.loader.ImageManager.getImageInfo(ImageManager.java:123)
      at org.apache.fop.fo.flow.ExternalGraphic.bind(ExternalGraphic.java:81)
      at org.apache.fop.fo.FObj.processNode(FObj.java:126)
      at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:291)
      at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:179)
      

      The issue XGC-30 sounds similiar but does not solve the problem.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              torsten.kuhnhenne Torsten Kuhnhenne
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: