When setting AbstractZipArchiver.recompressAddedZips to false already compressed entries should be added using the ZipEntry.STORED method. Unfortunately this doesn't appear to be the case.
The following can be added to ZipArchiverTest to demonstrate the issue.
public void testDontRecompressAddedZips() throws Exception {
final File srcDir = new File( "src/test/resources" );
final File zipFile = new File( "target/output/dont-recompress-added-zips.zip" );
ZipArchiver zipArchiver = getZipArchiver( zipFile );
zipArchiver.setRecompressAddedZips(false);
String[] includes = { "test.zip" };
zipArchiver.addDirectory( srcDir, includes, FileUtils.getDefaultExcludes() );
zipArchiver.setEncoding( "UTF-8" );
FileUtils.removePath( zipFile.getPath() );
zipArchiver.createArchive();
final ZipFile zf = new ZipFile( zipFile );
assertEquals( ZipEntry.STORED, zf.getEntry("test.zip").getMethod() );
zf.close();
}
The root cause appears to be due to changes introduced in 1ddd40b which push the header detection logic down to wrappedRecompressor.
Unfortunately this doesn't work because ConcurrentJarCreator.addArchiveEntry stores the mode at the time that then entry was added and ignores any subsequent updates. You can see this by adding a breakpoint in the constructor of ZipArchiveEntryRequest and another in ZipArchiveEntryRequest.getMethod().
When setting
AbstractZipArchiver.recompressAddedZipstofalsealready compressed entries should be added using theZipEntry.STOREDmethod. Unfortunately this doesn't appear to be the case.The following can be added to
ZipArchiverTestto demonstrate the issue.The root cause appears to be due to changes introduced in 1ddd40b which push the header detection logic down to
wrappedRecompressor.Unfortunately this doesn't work because
ConcurrentJarCreator.addArchiveEntrystores themodeat the time that then entry was added and ignores any subsequent updates. You can see this by adding a breakpoint in the constructor ofZipArchiveEntryRequestand another inZipArchiveEntryRequest.getMethod().