mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8292327: java.io.EOFException in InflaterInputStream after JDK-8281962
Reviewed-by: alanb, lancea
This commit is contained in:
parent
e61f6fc394
commit
802ef38060
3 changed files with 93 additions and 1 deletions
|
@ -101,6 +101,7 @@ public class Inflater {
|
|||
private byte[] inputArray;
|
||||
private int inputPos, inputLim;
|
||||
private boolean finished;
|
||||
private boolean pendingOutput;
|
||||
private boolean needDict;
|
||||
private long bytesRead;
|
||||
private long bytesWritten;
|
||||
|
@ -415,6 +416,11 @@ public class Inflater {
|
|||
if ((result >>> 62 & 1) != 0) {
|
||||
finished = true;
|
||||
}
|
||||
if (written == len && !finished) {
|
||||
pendingOutput = true;
|
||||
} else {
|
||||
pendingOutput = false;
|
||||
}
|
||||
if ((result >>> 63 & 1) != 0) {
|
||||
needDict = true;
|
||||
}
|
||||
|
@ -711,6 +717,10 @@ public class Inflater {
|
|||
throw new NullPointerException("Inflater has been closed");
|
||||
}
|
||||
|
||||
boolean hasPendingOutput() {
|
||||
return pendingOutput;
|
||||
}
|
||||
|
||||
private static native void initIDs();
|
||||
private static native long init(boolean nowrap);
|
||||
private static native void setDictionary(long addr, byte[] b, int off,
|
||||
|
|
|
@ -155,7 +155,12 @@ public class InflaterInputStream extends FilterInputStream {
|
|||
reachEOF = true;
|
||||
return -1;
|
||||
}
|
||||
if (inf.needsInput()) {
|
||||
if (inf.needsInput() && !inf.hasPendingOutput()) {
|
||||
// Even if needsInput() is true, the native inflater may have some
|
||||
// buffered data which couldn't fit in to the output buffer during the
|
||||
// last call to inflate. Consume that buffered data first before calling
|
||||
// fill() to avoid an EOF error if no more input is available and the
|
||||
// next call to inflate will finish the inflation.
|
||||
fill();
|
||||
}
|
||||
} while ((n = inf.inflate(b, off, len)) == 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue