RFR: 8341944: The zlib library no longer requires dummy byte for raw inflate
Eirik Bjørsnøs
eirbjo at openjdk.org
Fri Oct 11 15:16:50 UTC 2024
On Fri, 11 Oct 2024 08:11:37 GMT, Eirik Bjørsnøs <eirbjo at openjdk.org> wrote:
> Please review this cleanup PR which removes overrides of `InflaterInputStream.fill` in `ZipFileInflaterInputStream` and `ZipFileSystem::getInputStream`. Associated boolean fields used to track `eof` are also removed.
>
> These overrides exist to provide zlib with an extra dummy byte at the end of raw compressed streams (no wrapping):
>
>
> // Override fill() method to provide an extra "dummy" byte
> // at the end of the input stream. This is required when
> // using the "nowrap" Inflater option.
> protected void fill() throws IOException {
>
> However, zlib has not required such an extra dummy byte since 2003.
>
>
> Changes in 1.2.0 (9 March 2003)
> - New and improved inflate code
> - Raw inflate no longer needs an extra dummy byte at end
> ```
>
> The code in these overrides is effectively dead and removing it cleans up our code and reclaims weirdness dollars for our budget.
>
> Risk: I cannot imagine anyone is building OpenJDK with a 21 year old ZLIB. Please advise if this is the case or if any zlib fork in use still has this limitation.
>
> Testing: ZIP and ZIPFS tests run green locally. GHA results pending. No tests are added or modified, this is a cleanup-only PR. Manually verified that the code is dead by injecting AssertionErrors.
I have updated the `nowrap` constructor of `java.util.zip.Inflater` to remove the note about the extra 'dummy' input byte. I also tightened up the constructor to more clearly explain what the `nowrap` parameter does. The current "will not use" feels a bit loose. The `nowrap` parameter description is updated to not mention GZIP and instead just say "expect compressed input without ZLIB headers".
The matching constructor in `java.util.zip.Deflater` is updated to be consistent with the changes in `Inflater`. These should be easy to read side-by-side.
These API changes requires a CSR, which I plan to create once "more archaeological digging" deems this PR can continue safely.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/21467#issuecomment-2407618033
More information about the nio-dev
mailing list