From c07bd866840a1757f03ed57c5e376b9c5af4ed52 Mon Sep 17 00:00:00 2001 From: Jaikiran Pai Date: Fri, 7 Sep 2018 10:44:44 +0530 Subject: [PATCH] bz-62686 Correctly handle compression level changes in ZipOutputStream --- WHATSNEW | 4 ++++ src/main/org/apache/tools/zip/ZipOutputStream.java | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/WHATSNEW b/WHATSNEW index f67c79a19..9d96ca56d 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -12,6 +12,10 @@ Fixed bugs: instead of a IllegalStateException in the absence of the "id" attribute. Bugzilla Report 62655 + * org.apache.tools.zip.ZipOutputStream would sometimes potentially use + an incorrect compression level for a zip entry. This is now fixed. + Bugzilla Report 62686 + Other changes: -------------- * generatekey task now supports SubjectAlternativeName during key diff --git a/src/main/org/apache/tools/zip/ZipOutputStream.java b/src/main/org/apache/tools/zip/ZipOutputStream.java index f2117d853..ef850ee21 100644 --- a/src/main/org/apache/tools/zip/ZipOutputStream.java +++ b/src/main/org/apache/tools/zip/ZipOutputStream.java @@ -867,7 +867,10 @@ public class ZipOutputStream extends FilterOutputStream { throw new IllegalArgumentException("Invalid compression level: " + level); } - hasCompressionLevelChanged = (this.level != level); + if (this.level == level) { + return; + } + hasCompressionLevelChanged = true; this.level = level; }