@@ -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 )
0 commit comments