1717 * limitations under the License.
1818 */
1919
20+ import org .apache .commons .compress .archivers .zip .ParallelScatterZipCreator ;
2021import org .apache .commons .compress .archivers .zip .ZipArchiveEntry ;
2122import org .apache .commons .compress .archivers .zip .ZipArchiveOutputStream ;
2223import org .codehaus .plexus .archiver .ArchiverException ;
2526import org .codehaus .plexus .logging .console .ConsoleLogger ;
2627import org .codehaus .plexus .util .IOUtil ;
2728
29+ import javax .annotation .WillClose ;
2830import java .io .ByteArrayInputStream ;
2931import java .io .ByteArrayOutputStream ;
3032import java .io .File ;
@@ -284,7 +286,7 @@ public void addConfiguredIndexJars( File indexJar )
284286 indexJars .add ( indexJar .getAbsolutePath () );
285287 }
286288
287- protected void initZipOutputStream ( ZipArchiveOutputStream zOut )
289+ protected void initZipOutputStream ( ParallelScatterZipCreator zOut )
288290 throws ArchiverException , IOException
289291 {
290292 if ( !skipWriting )
@@ -334,15 +336,15 @@ private Manifest createManifest()
334336 return finalManifest ;
335337 }
336338
337- private void writeManifest ( ZipArchiveOutputStream zOut , Manifest manifest )
339+ private void writeManifest ( ParallelScatterZipCreator zOut , Manifest manifest )
338340 throws IOException , ArchiverException
339341 {
340342 for ( Enumeration e = manifest .getWarnings (); e .hasMoreElements (); )
341343 {
342344 getLogger ().warn ( "Manifest warning: " + e .nextElement () );
343345 }
344346
345- zipDir ( null , zOut , "META-INF/" , DEFAULT_DIR_MODE );
347+ zipDir ( null , zOut , "META-INF/" , DEFAULT_DIR_MODE , getEncoding () );
346348 // time to write the manifest
347349 ByteArrayOutputStream baos = new ByteArrayOutputStream ();
348350 manifest .write ( baos );
@@ -352,7 +354,7 @@ private void writeManifest( ZipArchiveOutputStream zOut, Manifest manifest )
352354 super .initZipOutputStream ( zOut );
353355 }
354356
355- protected void finalizeZipOutputStream ( ZipArchiveOutputStream zOut )
357+ protected void finalizeZipOutputStream ( ParallelScatterZipCreator zOut )
356358 throws IOException , ArchiverException
357359 {
358360 if ( index )
@@ -373,7 +375,7 @@ protected void finalizeZipOutputStream( ZipArchiveOutputStream zOut )
373375 * @throws org.codehaus.plexus.archiver.ArchiverException
374376 * .
375377 */
376- private void createIndexList ( ZipArchiveOutputStream zOut )
378+ private void createIndexList ( ParallelScatterZipCreator zOut )
377379 throws IOException , ArchiverException
378380 {
379381 ByteArrayOutputStream baos = new ByteArrayOutputStream ();
@@ -455,7 +457,7 @@ private void createIndexList( ZipArchiveOutputStream zOut )
455457 /**
456458 * Overridden from Zip class to deal with manifests and index lists.
457459 */
458- protected void zipFile ( InputStream is , ZipArchiveOutputStream zOut , String vPath , long lastModified , File fromArchive ,
460+ protected void zipFile ( @ WillClose InputStream is , ParallelScatterZipCreator zOut , String vPath , long lastModified , File fromArchive ,
459461 int mode , String symlinkDestination )
460462 throws IOException , ArchiverException
461463 {
@@ -534,23 +536,23 @@ protected boolean createEmptyZip( File zipFile )
534536 return true ;
535537 }
536538
537- ZipArchiveOutputStream zOut = null ;
538539 try
539540 {
540541 getLogger ().debug ( "Building MANIFEST-only jar: " + getDestFile ().getAbsolutePath () );
541- zOut = new ZipArchiveOutputStream ( bufferedOutputStream ( fileOutputStream ( getDestFile (), "jar" ) ));
542+ zipArchiveOutputStream = new ZipArchiveOutputStream ( bufferedOutputStream ( fileOutputStream ( getDestFile (), "jar" ) ));
542543
543- zOut .setEncoding ( getEncoding () );
544+ zipArchiveOutputStream .setEncoding (getEncoding ());
544545 if ( isCompress () )
545546 {
546- zOut .setMethod ( ZipArchiveOutputStream .DEFLATED );
547+ zipArchiveOutputStream .setMethod (ZipArchiveOutputStream .DEFLATED );
547548 }
548549 else
549550 {
550- zOut .setMethod ( ZipArchiveOutputStream .STORED );
551+ zipArchiveOutputStream .setMethod (ZipArchiveOutputStream .STORED );
551552 }
552- initZipOutputStream ( zOut );
553- finalizeZipOutputStream ( zOut );
553+ ParallelScatterZipCreator ps = new ParallelScatterZipCreator ();
554+ initZipOutputStream ( ps );
555+ finalizeZipOutputStream ( ps );
554556 }
555557 catch ( IOException ioe )
556558 {
@@ -559,7 +561,7 @@ protected boolean createEmptyZip( File zipFile )
559561 finally
560562 {
561563 // Close the output stream.
562- IOUtil .close ( zOut );
564+ // IOUtil.close( zOut );
563565 createEmpty = false ;
564566 }
565567 return true ;
0 commit comments