Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8239833

java.awt.Font.createFont(InputStream) leaking temporary files in webapps

XMLWordPrintable

    • 2d
    • x86_64
    • windows_10

      A DESCRIPTION OF THE PROBLEM :
      Using java.awt.Font.createFont(inputstream) will leak temporary file, as java internally copies this stream to temporary file, that is keeps open utill JVM shutdown.
      see https://github.com/frohoff/jdk8u-jdk/blob/master/src/share/classes/sun/f... createFont2D call.

      This causes an issue in webapp context - temporary files are left behind until application server restarts(tomcat).

      Cleanup at JVM shutdown is too late - all temporary files should get deleted when they're no longer needed.



      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1/start tomcat.
      2/deploy and start webapp there.
      3/make webapp call Font.createFont using Jnputstream to some font bundled in .war
      4/stop webapp.
      5/observe tomcat temp folder being polluted by +SF.. files.



      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      No leaked temporary files(and filedescriptors) in temp folder.
      ACTUAL -
      Temp folder gradually fills up with temporary files by each restart of application

      CUSTOMER SUBMITTED WORKAROUND :
      Only workaround is to use Font.createFont(File).

            prr Philip Race
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: