Category: | Patch |
Priority: | Normal |
Status: | New |
Project: | Severity: | Minor |
Resolution: | Open |
|
Component: | Reproducibility: | Sometimes |
Assigned to: |
The class net.sf.jasperreports.engine.util.JRSwapFile can leak a file descriptor. Over time, this can cause other parts of the program to fail in Unix with "Too many open files."
The JRSwapFile constructor unconditionally initializes the instance member "file" with a new RandomAccessFile, but dispose() closes it only conditionally. The attached patch updates dispose() to unconditionally close it.
v5.5.0
3 Comments:
Unconditionally closing the RandomAccessFile seems logical, but I'm trying to understand the scenario in which swapFile.exists() is false in dispose(). Do you have any details on how that happens?
Regards,
Lucian
I haven't been able to find a reasonable explanation as to why swapFile.exists() is false in dispose(). I suppose an external process could periodically delete the files in the swap file directory to clean up orphaned files from crashed JVMs (e.g., Java out of memory), but that is atypical and speculative.
Nevertheless, a previous examination of the JVM showed hundreds of accumulating swap files. After making this change, we stopped getting "Too many open files" errors, and the JVM no longer needs to be restarted periodically.