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

Threads using PDFBox getting stuck when using standard 14 fonts

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.0, 2.0.2, 2.0.3, 3.0.0 PDFBox
    • 2.0.3, 3.0.0 PDFBox
    • PDModel

    Description

      user prstahle reports:

      We have a relatively heavily threaded application which is calling pdfbox to stamp certain
      pdf files. We have been in production for a little over a week and have run into a few threads
      getting stuck. The stack trace is the following:

      ### Thread id=34, name="dispatch_2_20160626211454_1064"
      # ThreadInfo: "dispatch_2_20160626211454_1064" Id=34 RUNNABLE
      # CPU: threadCpuTime=49,541,548.824 ms, threadUserTime=49,538,533.066 ms
      # Contention: blockedCount=33 , blockedTime=123 ms
      # Contention: lockName=null , lockOwnerId=-1, lockOwnerName=null
      java.util.HashMap.put(HashMap.java:473)
      java.util.HashSet.add(HashSet.java:217)
      java.util.AbstractCollection.addAll(AbstractCollection.java:334)
      org.apache.pdfbox.pdmodel.font.encoding.Encoding.contains(Encoding.java:109)
      org.apache.pdfbox.pdmodel.font.PDType1Font.encode(PDType1Font.java:343)
      org.apache.pdfbox.pdmodel.font.PDFont.encode(PDFont.java:286)
      org.apache.pdfbox.pdmodel.font.PDFont.getStringWidth(PDFont.java:315)
      com.tycoelectronics.emcs.stamppdf.StampEnginePDFBox.getLongestTextWidth(StampEnginePDFBox.java:1369)
      

      We seem to be getting stuck in PDFont classes HashMap which is unsynchronized class.

      We are using "PDType1Font.HELVETICA".

      The problem is that for the standard 14 fonts, each font is a singleton, but its code is being used multithreaded, so we have to secure that.

      Attachments

        Activity

          People

            tilman Tilman Hausherr
            tilman Tilman Hausherr
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: