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

PDFont fails to close Font File.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.1.0
    • 1.5.0
    • FontBox
    • None

    Description

      Findbugs Reported this problem.

      I have include a patch which closes the file.

      BufferedReader in = new BufferedReader(new InputStreamReader(fontFile.getUnfilteredStream()));

      Bug: org.apache.pdfbox.pdmodel.font.PDFont.getEncodingFromFont() may fail to close stream
      Pattern id: OS_OPEN_STREAM, type: OS, category: BAD_PRACTICE

      The method creates an IO stream object, does not assign it to any fields, pass it to other methods that might close it, or return it, and does not appear to close the stream on all paths out of the method. This may result in a file descriptor leak. It is generally a good idea to use a finally block to ensure that streams are closed.

      Attachments

        1. PDFont.java
          32 kB
          Peter_Lenahan@ibi.com
        2. PDFont-Fails-toCloseFontFile.txt
          6 kB
          Peter_Lenahan@ibi.com

        Activity

          People

            lehmi Andreas Lehmkühler
            peter_lenahan@ibi.com Peter_Lenahan@ibi.com
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: