Skip to content

Commit b9a7316

Browse files
committed
Converted to use misc IOUtils instead of duplicating code
1 parent c1fffc6 commit b9a7316

File tree

1 file changed

+12
-36
lines changed

1 file changed

+12
-36
lines changed

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

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,18 @@
1818
*/
1919

2020
import java.io.File;
21-
import java.io.FileNotFoundException;
22-
import java.io.FileOutputStream;
2321
import java.io.IOException;
2422
import java.io.InputStream;
25-
import java.io.OutputStream;
2623
import java.net.URL;
2724
import java.util.Date;
2825
import java.util.Enumeration;
2926

3027
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
28+
import org.apache.commons.compress.utils.IOUtils;
3129
import org.codehaus.plexus.archiver.AbstractUnArchiver;
3230
import org.codehaus.plexus.archiver.ArchiveFilterException;
3331
import org.codehaus.plexus.archiver.ArchiverException;
34-
import org.codehaus.plexus.archiver.util.ArchiveEntryUtils;
3532
import org.codehaus.plexus.components.io.resources.PlexusIoResource;
36-
import org.codehaus.plexus.util.FileUtils;
3733
import org.codehaus.plexus.util.IOUtil;
3834

3935
/**
@@ -143,15 +139,15 @@ protected void execute()
143139
{
144140
final ZipArchiveEntry ze = (ZipArchiveEntry) e.nextElement();
145141
final ZipEntryFileInfo fileInfo = new ZipEntryFileInfo( zf, ze );
146-
if ( !isSelected( ze.getName(), fileInfo ) )
142+
if ( isSelected( ze.getName(), fileInfo ) )
147143
{
148-
continue;
149-
}
150-
InputStream in = zf.getInputStream( ze );
151-
extractFileIfIncluded( getSourceFile(), getDestDirectory(), in, ze.getName(),
152-
new Date( ze.getTime() ), ze.isDirectory(), ze.getUnixMode()!= 0 ? ze.getUnixMode() : null );
153-
in.close();
154-
}
144+
InputStream in = zf.getInputStream( ze );
145+
extractFileIfIncluded(getSourceFile(), getDestDirectory(), in, ze.getName(),
146+
new Date(ze.getTime()), ze.isDirectory(), ze.getUnixMode() != 0 ? ze.getUnixMode() : null);
147+
IOUtil.close(in);
148+
}
149+
150+
}
155151

156152
getLogger().debug( "expand complete" );
157153
}
@@ -161,17 +157,7 @@ protected void execute()
161157
}
162158
finally
163159
{
164-
if ( zf != null )
165-
{
166-
try
167-
{
168-
zf.close();
169-
}
170-
catch ( final IOException e )
171-
{
172-
// ignore
173-
}
174-
}
160+
IOUtils.closeQuietly( zf);
175161
}
176162
}
177163

@@ -219,7 +205,7 @@ protected void execute( final String path, final File outputDirectory )
219205
extractFileIfIncluded( getSourceFile(), outputDirectory, inputStream,
220206
ze.getName(), new Date( ze.getTime() ), ze.isDirectory(),
221207
ze.getUnixMode() != 0 ? ze.getUnixMode() : null );
222-
inputStream.close();
208+
IOUtil.close(inputStream);
223209
}
224210
}
225211
}
@@ -229,17 +215,7 @@ protected void execute( final String path, final File outputDirectory )
229215
}
230216
finally
231217
{
232-
if ( zipFile != null )
233-
{
234-
try
235-
{
236-
zipFile.close();
237-
}
238-
catch ( final IOException e )
239-
{
240-
// ignore
241-
}
242-
}
218+
IOUtils.closeQuietly( zipFile);
243219
}
244220
}
245221
}

0 commit comments

Comments
 (0)