Skip to content

Commit 5ad33c9

Browse files
committed
Made closing of iterated resources happen after archiver is closed
1 parent d9cb6a8 commit 5ad33c9

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/main/java/org/codehaus/plexus/archiver/AbstractArchiver.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ public abstract class AbstractArchiver
108108
// On lunix-like systems, we replace windows backslashes with forward slashes
109109
private final boolean replacePathSlashesToJavaPaths = File.separatorChar == '/';
110110

111+
private final List<Closeable> closeables = new ArrayList<Closeable>( );
111112
/**
112113
* since 2.2 is on by default
113114
*
@@ -523,7 +524,7 @@ else if ( o instanceof PlexusIoResourceCollection )
523524
// to the client and ditch the whole issue onto the client.
524525
// this does not really make any sense either, might equally well change the
525526
// api into something that is not broken by design.
526-
closeQuietlyIfCloseable( ioResourceIter );
527+
addCloseable( ioResourceIter );
527528
ioResourceIter = null;
528529
}
529530
}
@@ -1041,12 +1042,27 @@ protected void validate()
10411042

10421043
protected abstract String getArchiveType();
10431044

1045+
private void addCloseable(Object maybeCloseable){
1046+
if (maybeCloseable instanceof Closeable)
1047+
closeables.add( (Closeable) maybeCloseable );
1048+
1049+
}
1050+
private void closeIterators()
1051+
{
1052+
for ( Closeable closeable : closeables )
1053+
{
1054+
closeQuietlyIfCloseable( closeable );
1055+
}
1056+
1057+
}
10441058
protected abstract void close()
10451059
throws IOException;
10461060

10471061
protected void cleanUp()
10481062
throws IOException
10491063
{
1064+
closeIterators();
1065+
10501066
for ( Object resource : resources )
10511067
{
10521068
if ( resource instanceof PlexusIoProxyResourceCollection )

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ protected Iterator<PlexusIoResource> getEntries()
3232
{
3333
throw new IOException( "The tar archive file has not been set." );
3434
}
35-
final ZipFile zipFile = new ZipFile( f, charset.name() );
35+
final ZipFile zipFile = new ZipFile( f, charset != null ? charset.name() : "UTF8");
3636
return new CloseableIterator( zipFile );
3737
}
3838

0 commit comments

Comments
 (0)