Skip to content

Commit 6654fae

Browse files
committed
Fix file descriptor leak
`JarArchiver` and `PlexusIoZipFileResourceCollection` use `Closeable` classes but does not close them. That leads to file descriptor leaks as the opened files are not closed. Fixes #79
1 parent 01e2fe6 commit 6654fae

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/main/java/org/codehaus/plexus/archiver/jar/JarArchiver.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,10 @@ protected void zipFile( InputStreamSupplier is, ConcurrentJarCreator zOut, Strin
484484
{
485485
if ( !doubleFilePass || skipWriting )
486486
{
487-
filesetManifest( fromArchive, is.get() );
487+
try ( InputStream manifestInputStream = is.get() )
488+
{
489+
filesetManifest( fromArchive, manifestInputStream );
490+
}
488491
}
489492
}
490493
else if ( INDEX_NAME.equalsIgnoreCase( vPath ) && index )

src/main/java/org/codehaus/plexus/archiver/zip/PlexusIoZipFileResourceCollection.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,14 @@ public void remove()
196196
public void close()
197197
throws IOException
198198
{
199-
zipFile.close();
199+
try
200+
{
201+
urlClassLoader.close();
202+
}
203+
finally
204+
{
205+
zipFile.close();
206+
}
200207
}
201208

202209
}

0 commit comments

Comments
 (0)