RFR: 8326099: GZIPOutputStream should use Deflater.getBytesRead() instead of Deflater.getTotalIn()
Eirik Bjørsnøs
eirbjo at openjdk.org
Sat Feb 17 12:42:05 UTC 2024
Please review this cleanup PR in preparation for deprecating `Deflater.getTotalIn()` in JDK-8326096.
This PR replaces `GZIPOutputStream.writeTrailer`'s call to `Deflater.getTotalIn()` with a call to `Deflater.getBytesRead()` followed by an explicit conversion to "modulo 2^32" (a cast to int) as described in RFC 1952:
ISIZE (Input SIZE)
This contains the size of the original (uncompressed) input
data modulo 2^32.
Testing and verification: This should be trivially verifiable by code inspection. Nevertheless, I wrote a test which writes Integer.MAX_VALUE +1 bytes of uncompressed data and verified that the last four bytes written to the file was indeed as expected. (This test is not included in this PR because of its runtime and resource requirements).
-------------
Commit messages:
- Update copyright year
- Update GZIPOutputStream.writeTrailer to use Deflater.getBytesRead() instead of Deflater.getTotalIn()
Changes: https://git.openjdk.org/jdk/pull/17900/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=17900&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8326099
Stats: 4 lines in 1 file changed: 2 ins; 0 del; 2 mod
Patch: https://git.openjdk.org/jdk/pull/17900.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/17900/head:pull/17900
PR: https://git.openjdk.org/jdk/pull/17900
More information about the core-libs-dev
mailing list