Ensure we always encode all data in JdkZlibEncoder. (#8305)

Motivation:

In theory our estimation of the needed buffer could be off and so we need to ensure we grow it if there is no space left.

Modifications:

Ensure we grow the buffer if there is no space left in there but we still have data to deflate.

Result:

Correctly deflate data in all cases.
This commit is contained in:
Norman Maurer 2018-09-22 13:34:12 -07:00 committed by GitHub
parent a80c49828f
commit 9a3be347af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -225,8 +225,18 @@ public class JdkZlibEncoder extends ZlibEncoder {
}
deflater.setInput(inAry, offset, len);
while (!deflater.needsInput()) {
for (;;) {
deflate(out);
if (deflater.needsInput()) {
// Consumed everything
break;
} else {
if (!out.isWritable()) {
// We did not consume everything but the buffer is not writable anymore. Increase the capacity to
// make more room.
out.ensureWritable(out.writerIndex());
}
}
}
}