Skip to content

Commit b08f77a

Browse files
committed
Cleanup after "veryLargeJar" test
1 parent 5888c8e commit b08f77a

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

Diff for: src/test/java/org/codehaus/plexus/archiver/jar/JarArchiverTest.java

+9-7
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,18 @@ public void testNonCompressed() throws IOException, ManifestException, ArchiverE
5555
}
5656

5757
@Test
58-
public void testVeryLargeJar() throws IOException, ManifestException, ArchiverException {
58+
public void testVeryLargeJar() throws IOException, ArchiverException {
5959
// Generate some number of random files that is likely to be
6060
// two or three times the number of available file handles
6161
Random rand = new Random();
6262
for (int i = 0; i < 45000; i++) {
6363
Path path = tempDir.resolve("file" + i);
64-
OutputStream out = Files.newOutputStream(path);
65-
byte[] data = new byte[512]; // 512bytes per file
66-
rand.nextBytes(data);
67-
out.write(data);
68-
out.flush();
69-
out.close();
64+
try (OutputStream out = Files.newOutputStream(path)) {
65+
byte[] data = new byte[512]; // 512bytes per file
66+
rand.nextBytes(data);
67+
out.write(data);
68+
out.flush();
69+
}
7070
}
7171

7272
File jarFile = new File("target/output/veryLargeJar.jar");
@@ -75,6 +75,8 @@ public void testVeryLargeJar() throws IOException, ManifestException, ArchiverEx
7575
archiver.setDestFile(jarFile);
7676
archiver.addDirectory(tempDir.toFile());
7777
archiver.createArchive();
78+
// Clean up
79+
Files.delete(jarFile.toPath());
7880
}
7981

8082
@Test

0 commit comments

Comments
 (0)