JDK-8183349 : Better cleanup for jdk/test/javax/imageio/plugins/shared/CanWriteSequence.java and WriteAfterAbort.java
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.imageio
  • Affected Version: 10
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2017-07-01
  • Updated: 2020-10-12
  • Resolved: 2017-07-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 10 JDK 8 Other
10 b23Fixed 8u270Fixed openjdk8u272Fixed
Related Reports
Relates :  
Description
CanWriteSequence.java and WriteAfterAbort.java are creating files in the system default temp directory:

% cat -n jdk/test/javax/imageio/plugins/shared/CanWriteSequence.java jdk/test/javax/imageio/plugins/shared/WriteAfterAbort.java | grep createTemp
    57          final File file = File.createTempFile("temp", ".img");
    68          final File file = File.createTempFile("temp", ".img");


These files are left behind, even though the tests also set file.deleteOnExit():

The preferred approach would be to create temporary test directories and files under the jtreg property test.dir instead, if it is defined. 
Comments
Fix Request (8u) I would like to backport this to 8u for parity with Oracle 8u271. The original patch does not apply cleanly, due to missing a new line at the end of file in 8u. After adding the new line, patch applies cleanly. Code review thread: https://mail.openjdk.java.net/pipermail/jdk8u-dev/2020-June/011992.html
21-07-2020

Where you take a look a temporary files at the beginning? I guess it should be tmp folder in the cygwin. (c:/cygwin/tmp) Hello Sergey, I checked in Windows temporary folder, cygwin temporary folder and Local/AppData temporary folder also. I didn't see temporary files at these locations. Thanks, Jay
17-07-2017

Where you take a look a temporary files at the beginning? I guess it should be tmp folder in the cygwin. (c:/cygwin/tmp)
10-07-2017

I created file in local directory and after that started seeing temporary files. The root cause was FileOutputStream was not closed and only ImageOutputStream was closed. I will be making changes to replace file.deleteOnExit() with Files.delete().
10-07-2017

At least the file.deleteOnExit(); should be replaced by "Files.delete(Paths.get(file.getAbsolutePath()));" which will throw an exception if the file cannot be deleted(for example if it was locked by some class).
07-07-2017

When a test is run under jtreg, the property 'user.dir' is set to $PWD/JTwork/scratch This would be a good place to create temporary files or directories that are only needed for the duration of the test run.
07-07-2017

Please reopen with response
06-07-2017

Ran both test cases through jtreg in Windows 7 machine multiple times. Both tests are passing and there are no temporary files left behind. Does temporary files are not getting deleted only when test case fails sometimes? Need more information.
06-07-2017