Repository navigation
Read HDF5 filter ids as unsigned 16-bit values - #1625
Merged
Merged
Conversation
HDF5 filter ids are unsigned. Ids from 32768 to 65535 were read as negative shorts, so the filter provider lookup failed, and in version 2 filter pipeline messages the name length field was skipped, which misaligned the rest of the message. The old H5header failed with an ArrayIndexOutOfBoundsException for the same files. Refs Unidata#1620 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lesserwhirls
approved these changes
Nov 23, 2026
lesserwhirls
left a comment
Member
There was a problem hiding this comment.
Thank you for this contribution. This looks good to me.
5 tasks done
lesserwhirls
added a commit
to lesserwhirls/netcdf-java
that referenced
this pull request
Nov 26, 2026
Fix integration test regression due to new test files introduced in blosc2 compression PR (Unidata#1625)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thank you for the prompt review and merge of #1621, and for the follow-up on the zstd plan. As promised, here is the small separate PR for the unsigned filter id.
Part of #1620 (the "filter id parsed as signed short" side note).
Problem
HDF5 filter ids are unsigned 16-bit values, but the filter pipeline message reads them with
readShort(). Ids from 32768 to 65535 (the range HDF5 leaves for unregistered filters) become negative:Filters.getFilterlooks up-25536instead of40000, so a registered provider is never found (UnknownFilterException: no filter found with id -25536).id < 256is true for a negative id, so the field is skipped and the rest of the message is misaligned (the filter parameters{7}were read as{458753}).ucar.nc2.iosp.hdf5.H5headerfails on the same files withArrayIndexOutOfBoundsException: Index -25536ingetFilterName.Change
H5objects.MessageFilter: compare the id as unsigned for the name length check;Filter.getId()returns the unsigned value.Filters.getFilter: convert aShortid withShort.toUnsignedInt; otherNumbertypes useintValue(). The value stored underFilters.Keys.IDis still aShort, so existing providers and callers see the same type as before.H5header.Filter: read the id withreadUnsignedShort()into anint.Tests
TestH5FilterIdUnsignedwith two small files (11-13 KB) that use the optional filter 40000 with cd_values{7}, one with a version 1 and one with a version 2 filter pipeline message. They were made with HDF5 1.10.5h5repack -f v:UD=40000,1,1,7(the version 2 file with--low=1 --high=1). The filter was not available when they were written, so the chunks are stored unfiltered with the filter mask set and the data can be checked without a real filter. A pass-through test provider is registered for id 40000.(short) 40000)Without the change all three tests fail; with only the name length check reverted, the version 2 test fails on the filter parameters. The parameterized
TestN3iospCompareandTestCoordSysComparealso pick up the new files and exercise the oldH5header../gradlew :cdm-core:spotlessCheck :cdm-core:testWithJdk25passes locally except for twoTestMFileOStests that fail the same way on unmodifiedmaint-5.xon Windows (path separators).🤖 Generated with Claude Code