Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-3015

PDICCBased loadICCProfile() throwing ConcurrentModificationException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 2.0.0
    • None
    • Rendering
    • None
    • Windows 8.1 Pro
      java 6-8
      tomcat 6-7

    Description

      When running a load test using PDFRenderer's method renderImageWithDPI(pageIndex, 175), I am receiving a ConcurrentModificationException. I only receive this using Java 6-8 and Tomcat 6 or 7 but Tomcat 8 seems to work. I can reproduce this with as little as 4 concurrent threads kicked off at the same time. It only happens the first time the method is called (server startup), after that it works fine.

      Here is the stacktrace:

      java.util.ConcurrentModificationException
      at java.util.Vector$Itr.checkForComodification(Vector.java:1156)
      at java.util.Vector$Itr.next(Vector.java:1133)
      at sun.java2d.cmm.ProfileDeferralMgr.activateProfiles(ProfileDeferralMgr.java:93)
      at java.awt.color.ICC_Profile.getInstance(ICC_Profile.java:775)
      at java.awt.color.ICC_Profile.getInstance(ICC_Profile.java:1013)
      at org.apache.pdfbox.pdmodel.graphics.color.PDICCBased.loadICCProfile(PDICCBased.java:119)
      at org.apache.pdfbox.pdmodel.graphics.color.PDICCBased.<init>(PDICCBased.java:89)
      at org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace.create(PDColorSpace.java:162)
      at org.apache.pdfbox.pdmodel.PDResources.getColorSpace(PDResources.java:155)
      at org.apache.pdfbox.contentstream.operator.color.SetStrokingColorSpace.process(SetStrokingColorSpace.java:41)
      at org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:799)
      at org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:461)
      at org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:438)
      at org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:149)
      at org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:180)
      at org.apache.pdfbox.rendering.PDFRenderer.renderPage(PDFRenderer.java:208)
      at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:139)
      at org.apache.pdfbox.rendering.PDFRenderer.renderImageWithDPI(PDFRenderer.java:80)

      Since the problem was with a java class not being synchronized, I added a simple static synchronized method to PDICCBased.java to load the profile and prevent the race condition:

      private static synchronized ICC_Profile getICCProfile(InputStream input) throws IOException {
      return ICC_Profile.getInstance(input);
      }

      And call it from the loadICCProfile method:

      ICC_Profile profile = PDICCBased.getICCProfile(input);

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jasonmackin Jason Mackin
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: