-
Bug
-
Resolution: Fixed
-
P3
-
21
-
b26
Colleague Tobias Thierer writes:
=====
When the constructor GZIPInputStream(InputStream,int) throws an exception (eg. when encountering invalid data), the Inflater constructed earlier is not end()ed before it becomes eligible for garbage collection. This means that the Inflater's zsref is not reliably cleared (relies on finalization alone).
The patch below fixes this problem in the case of Exception; in the case of Error, it still leaves the Inflater in un-end()ed state.
--- a/src/java.base/share/classes/java/util/zip/GZIPInputStream.java Thu Jun 21 08:58:59 2018 -0300
+++ b/src/java.base/share/classes/java/util/zip/GZIPInputStream.java Thu Sep 06 14:15:23 2018 +0100
@@ -77,7 +77,12 @@
public GZIPInputStream(InputStream in, int size) throws IOException {
super(in, new Inflater(true), size);
usesDefaultInflater = true;
- readHeader(in);
+ try {
+ readHeader(in);
+ } catch (Exception e) {
+ inf.end();
+ throw e;
+ }
}
/**
=====
When the constructor GZIPInputStream(InputStream,int) throws an exception (eg. when encountering invalid data), the Inflater constructed earlier is not end()ed before it becomes eligible for garbage collection. This means that the Inflater's zsref is not reliably cleared (relies on finalization alone).
The patch below fixes this problem in the case of Exception; in the case of Error, it still leaves the Inflater in un-end()ed state.
--- a/src/java.base/share/classes/java/util/zip/GZIPInputStream.java Thu Jun 21 08:58:59 2018 -0300
+++ b/src/java.base/share/classes/java/util/zip/GZIPInputStream.java Thu Sep 06 14:15:23 2018 +0100
@@ -77,7 +77,12 @@
public GZIPInputStream(InputStream in, int size) throws IOException {
super(in, new Inflater(true), size);
usesDefaultInflater = true;
- readHeader(in);
+ try {
+ readHeader(in);
+ } catch (Exception e) {
+ inf.end();
+ throw e;
+ }
}
/**
- links to
-
Commit openjdk/jdk/d9e7b7e7
-
Review openjdk/jdk/19475
-
Review(master) openjdk/jdk21u-dev/1725