quality: thread-safety docs, null validation, shared sentinels#22
Merged
Conversation
…tinels Follow-ups from the code-quality inspection: - Thread-safety docs (#2): document the four streams as not thread-safe (confine to one thread) and the two digested dictionaries as immutable and safe to share across threads. - Null validation (#3): fail fast with a named NullPointerException on public byte[]/dictionary/sample/stream arguments instead of an opaque NPE deep in native code. requireNative now also rejects null, covering every MemorySegment entry point. - Sentinel DRY (#4): one definition of CONTENTSIZE_UNKNOWN/_ERROR in Zstd, reused by ZstdFrame and ZstdFrameHeader (drops a duplicate and the CONTENT_SIZE_ERROR naming drift). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Code-quality inspection follow-ups (#2–#4; #1 defensive copy is in #21).
#2 Thread-safety docs
ZstdInputStream/ZstdOutputStream/ZstdCompressStream/ZstdDecompressStream: documented not thread-safe (confine to one thread) — same hazard the ctx classes already document.ZstdCompressDict/ZstdDecompressDict: documented immutable and safe to share across threads (the digested dictionary is read-only), since users pool them.#3 Null validation
Fail fast with a named
NullPointerExceptioninstead of an opaque NPE deep in native code:requireNativenowrequireNonNulls first → covers every publicMemorySegmententry point.Objects.requireNonNullon the publicbyte[]/ZstdDictionary/List<byte[]> samples/ streamout/inarguments acrossZstd, the contexts,ZstdDictionary, the digested dicts, and the java.io streams. (Streamdictionarystays nullable = "no dictionary".)rejectsNullInputWithANamedMessage.#4 Sentinel DRY
One definition of
CONTENTSIZE_UNKNOWN(-1) /CONTENTSIZE_ERROR(-2) inZstd, reused byZstdFrameandZstdFrameHeader— removes the duplicates and theCONTENT_SIZE_ERRORnaming drift.Test
./mvnw -pl zstd,integration-tests -am verify— 142 unit + 79 integration green, checkstyle + javadoc clean.🤖 Generated with Claude Code