|
23 | 23 | import java.io.InputStream;
|
24 | 24 | import java.io.OutputStream;
|
25 | 25 | import java.io.SequenceInputStream;
|
| 26 | +import java.nio.ByteBuffer; |
26 | 27 | import java.nio.charset.Charset;
|
27 | 28 | import java.util.Hashtable;
|
28 | 29 | import java.util.Stack;
|
@@ -502,8 +503,7 @@ protected void zipFile( InputStreamSupplier in, ConcurrentJarCreator zOut, Strin
|
502 | 503 | InputStream payload;
|
503 | 504 | if ( ze.isUnixSymlink() )
|
504 | 505 | {
|
505 |
| - ZipEncoding enc = ZipEncodingHelper.getZipEncoding( getEncoding() ); |
506 |
| - final byte[] bytes = enc.encode( symlinkDestination ).array(); |
| 506 | + final byte[] bytes = encodeArchiveEntry( symlinkDestination, getEncoding() ); |
507 | 507 | payload = new ByteArrayInputStream( bytes );
|
508 | 508 | zOut.addArchiveEntry( ze, createInputStreamSupplier( payload ), true );
|
509 | 509 | }
|
@@ -644,14 +644,24 @@ protected void zipDir( PlexusIoResource dir, ConcurrentJarCreator zOut, String v
|
644 | 644 | else
|
645 | 645 | {
|
646 | 646 | String symlinkDestination = ( (SymlinkDestinationSupplier) dir ).getSymlinkDestination();
|
647 |
| - ZipEncoding enc = ZipEncodingHelper.getZipEncoding( encodingToUse ); |
648 |
| - final byte[] bytes = enc.encode( symlinkDestination ).array(); |
| 647 | + final byte[] bytes = encodeArchiveEntry( symlinkDestination, encodingToUse ); |
649 | 648 | ze.setMethod( ZipArchiveEntry.DEFLATED );
|
650 | 649 | zOut.addArchiveEntry( ze, createInputStreamSupplier( new ByteArrayInputStream( bytes ) ), true );
|
651 | 650 | }
|
652 | 651 | }
|
653 | 652 | }
|
654 | 653 |
|
| 654 | + private byte[] encodeArchiveEntry( String payload, String encoding ) |
| 655 | + throws IOException |
| 656 | + { |
| 657 | + ZipEncoding enc = ZipEncodingHelper.getZipEncoding( encoding ); |
| 658 | + ByteBuffer encodedPayloadByteBuffer = enc.encode( payload ); |
| 659 | + byte[] encodedPayloadBytes = new byte[encodedPayloadByteBuffer.limit()]; |
| 660 | + encodedPayloadByteBuffer.get( encodedPayloadBytes ); |
| 661 | + |
| 662 | + return encodedPayloadBytes; |
| 663 | + } |
| 664 | + |
655 | 665 | protected InputStreamSupplier createInputStreamSupplier( final InputStream inputStream )
|
656 | 666 | {
|
657 | 667 | return new InputStreamSupplier()
|
|
0 commit comments