Fix repackaging of jars with non-default compression configuration

Previously, if a jar that used custom compression configuration was
repackaged, a failure may occur if an entry in the repackaged jar had
a different compressed size to the entry in the source jar.

This commit updates JarWriter to clear the input entry's compressed
size (by setting it to -1) so that the repackaged entry's compressed
size does not have to match that of the input entry.

Closes gh-13720
This commit is contained in:
Andy Wilkinson
2018-07-09 13:16:41 +01:00
parent 9a49e8ef73
commit a50646b7cc
2 changed files with 30 additions and 1 deletions

View File

@@ -140,6 +140,9 @@ public class JarWriter implements LoaderClassesWriter {
inputStream = new ZipHeaderPeekInputStream(
jarFile.getInputStream(entry));
}
else {
entry.setCompressedSize(-1);
}
EntryWriter entryWriter = new InputStreamEntryWriter(inputStream, true);
JarEntry transformedEntry = entryTransformer.transform(entry);
if (transformedEntry != null) {