JDK-6474389 : test/java/util/zip/ZipFile/ManyZipFiles.java should clean up after itself
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.jar
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2006-09-22
  • Updated: 2011-05-17
  • Resolved: 2011-05-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 7
7 b03Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
The ManyZipFiles test creates "numFiles = 3000" .zip files to verify
that 6423026 is fixed.

It exits with a 'pass' or 'fail' but does not clean up the temporary .zip
files generated during the test.  On shared testing machines with nightly
test runs the temp directory quickly fills up with dirt and spurious test
failures start to creep in because of that.


An example using one of our nightly test machines:

(otto@roque) ~ $ ls -l /c/winnt/test9999* 
-rwx------+ 1 otto None 136 Jul 13 05:22 /c/winnt/test9999.zip
-rwx------+ 1 otto None 136 Aug 21 05:23 /c/winnt/test99990.zip
-rwx------+ 1 otto None 136 Aug 21 05:23 /c/winnt/test99991.zip
-rwx------+ 1 otto None 136 Aug 21 05:23 /c/winnt/test99992.zip
-rwx------+ 1 otto None 136 Aug 21 05:23 /c/winnt/test99993.zip
-rwx------+ 1 otto None 136 Aug 21 05:23 /c/winnt/test99994.zip
-rwx------+ 1 otto None 136 Aug 21 05:23 /c/winnt/test99995.zip
-rwx------+ 1 otto None 136 Aug 21 05:23 /c/winnt/test99996.zip
-rwx------+ 1 otto None 136 Aug 21 05:23 /c/winnt/test99997.zip
-rwx------+ 1 otto None 136 Aug 21 05:23 /c/winnt/test99998.zip
-rwx------+ 1 otto None 136 Aug 21 05:23 /c/winnt/test99999.zip

(otto@roque) ~ $ ls -1 /c/winnt | wc -l
147369

Comments
EVALUATION Problem is that ZipFile's constructor leaves the file open, and so due to 4171239 they don't get deleted.
22-09-2006

SUGGESTED FIX (Second try as my first suggestion was quite broken) The attachment ManyZipFiles.java has also been updated. % sccs diffs ManyZipFiles.java ------- ManyZipFiles.java ------- 43,53c43,56 < for (int i = 0; i < numFiles; i++) { < File f = File.createTempFile("test", ".zip"); < FileOutputStream fos = new FileOutputStream(f); < fos.write(data, 0, data.length); < fos.close(); < f.deleteOnExit(); < try { < zips[i] = new ZipFile(f); < } catch (Throwable t) { < fail("Failed to open zip file #" + i); < throw t; --- > File fd = new File(System.getProperty("user.dir")); > try { > for (int i = 0; i < numFiles; i++) { > File f = File.createTempFile("test", ".zip", fd); > FileOutputStream fos = new FileOutputStream(f); > fos.write(data, 0, data.length); > fos.close(); > f.deleteOnExit(); > try { > zips[i] = new ZipFile(f); > } catch (Throwable t) { > fail("Failed to open zip file #" + i); > throw t; > } 54a58,62 > } finally { > for (int i = 0; i < numFiles; i++) { > if (zips[i] != null) > zips[i].close(); > }
22-09-2006