...
This example also uses the deleteOnExit()
method to ensure that the temporary file is deleted when the Java Virtual Machine (JVM) terminates. However, according to the Java API [API 2006] Class File
, method deleteOnExit()
documentation,
...
Consequently, the file is not deleted if the JVM terminates unexpectedly. A longstanding bug on Windows-based systems reported as Bug ID: 4171239 [SDN 2008] causes JVMs to fail to delete a file when deleteOnExit()
is invoked before the associated stream or RandomAccessFile
is closed.
...
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
FIO03-J | Medium | Probable | Medium | P8 | L2 |
Related Guidelines
FIO21-C. Do not create temporary files in shared directories | |
FIO19-CPP. Do not create temporary files in shared directories | |
CWE-377. Insecure temporary file | |
| CWE-459. Incomplete cleanup |
Bibliography
[API 2006] | Class |
11.5, Creating a Transient File | |
| |
[SDN 2008] | Bug IDs 4171239, 4405521, 4635827, 4631820 |
...