Uploaded image for project: 'FOP'
  1. FOP
  2. FOP-1594

Synchronization fault in FontCache

    Details

    • Type: Bug
    • Status: Closed
    • Resolution: Fixed
    • Affects Version/s: 0.95
    • Fix Version/s: None
    • Component/s: font/unqualified
    • Labels:
      None
    • Environment:
      Operating System: Linux
      Platform: PC
    • External issue ID:
      46211

      Description

      I have an application which renders a lot of PDFs using several threads. We had an issue recently, concerning font loading. While investigating this stack trace:

      java.lang.NullPointerException
      at org.apache.fop.fonts.FontCache.isFailedFont(FontCache.java:294)
      at org.apache.fop.fonts.autodetect.FontInfoFinder.find(FontInfoFinder.java:179)
      at org.apache.fop.render.PrintRendererConfigurator.addFontInfoListFromFileList(PrintRendererConfigurator.java:233)
      at org.apache.fop.render.PrintRendererConfigurator.buildFontListFromConfiguration(PrintRendererConfigurator.java:140)
      at org.apache.fop.render.PrintRendererConfigurator.configure(PrintRendererConfigurator.java:95)
      at org.apache.fop.render.pdf.PDFRendererConfigurator.configure(PDFRendererConfigurator.java:71)
      at org.apache.fop.render.RendererFactory.createRenderer(RendererFactory.java:187)
      at org.apache.fop.area.RenderPagesModel.<init>(RenderPagesModel.java:68)
      at org.apache.fop.area.AreaTreeHandler.setupModel(AreaTreeHandler.java:127)
      at org.apache.fop.area.AreaTreeHandler.<init>(AreaTreeHandler.java:102)
      at org.apache.fop.render.RendererFactory.createFOEventHandler(RendererFactory.java:224)
      at org.apache.fop.fo.FOTreeBuilder.<init>(FOTreeBuilder.java:100)
      at org.apache.fop.apps.Fop.createDefaultHandler(Fop.java:100)
      at org.apache.fop.apps.Fop.<init>(Fop.java:78)
      at org.apache.fop.apps.FopFactory.newFop(FopFactory.java:247)

      I have found a possible synchronization fault in FontCache method:

      == Java code ==
      public boolean isFailedFont(String embedUrl, long lastModified) {
      if (failedFontMap.containsKey(embedUrl)) {
      synchronized (changeLock) {
      long failedLastModified = ((Long)failedFontMap.get(embedUrl)).longValue();
      if (lastModified != failedLastModified)

      { // this font has been changed so lets remove it // from failed font map for now failedFontMap.remove(embedUrl); changed = true; }
      }
      return true;
      }
      return false;
      }
      == end Java code ==

      to my opinion, it shall be like this:

      == Java code ==
      public boolean isFailedFont(String embedUrl, long lastModified) {
      synchronized (changeLock) {
      if (failedFontMap.containsKey(embedUrl)) {

      long failedLastModified = ((Long)failedFontMap.get(embedUrl)).longValue();
      if (lastModified != failedLastModified) { // this font has been changed so lets remove it // from failed font map for now failedFontMap.remove(embedUrl); changed = true; }

      return true;
      }
      return false;
      }
      }
      == end Java code ==

        Attachments

        1. bugzilla46211.diff
          3 kB
          Andreas L. Delmelle

          Activity

            People

            • Assignee:
              fop-dev@xmlgraphics.apache.org fop-dev
              Reporter:
              rogov@devexperts.com ilj
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: