JDK-8239833 : java.awt.Font.createFont(InputStream) leaking temporary files in webapps
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 8u241,13.0.2
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_10
  • CPU: x86_64
  • Submitted: 2020-02-13
  • Updated: 2020-02-24
  • Resolved: 2020-02-24
Related Reports
Duplicate :  
Description
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).


Comments
There is no leak. That assertion is not correct. The files continue to be tracked and will be freed eventually. However the freeing is less prompt than it could be and that is resolved by JDK-8209113 (fixed in JDK 14) so I am closing this as a duplicate.
24-02-2020

does it affect 15? 11u?
24-02-2020

As per description, java.awt.Font.createFont(InputStream) leaks temporary files in webapps. As per submitter, issue does affect JDK 8u241 as well as 13.0.2. Attached test case as shared by the submitter.
24-02-2020