Conversation
…ns null CreatePartitionsRequest validates partitionOptions with contains(null), and List.of answers that with a NullPointerException rather than false. A caller handing over a valid immutable list therefore gets an NPE from the guard whose job is to give it a clear message, with a stack that points at the collection instead of at the argument. Ask with a null-safe stream instead.
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.
Purpose
CreatePartitionsRequestvalidates itspartitionOptionswithList.of(...)rejectsnullqueries, socontains(null)throwsNullPointerExceptioninstead of returningfalse. A caller that passes a perfectly valid immutable list therefore gets an NPE out of the guard whose job is to explain what is wrong with the argument, and the stack points intoImmutableCollections, not at the request:Found while writing a test that registers a Format Table partition at a custom location through
RESTApi.createPartitions. The server side is unaffected — Jackson deserializes into anArrayList— so this only bites Java clients and test fixtures that build the list withList.of.Tests
RESTApiJsonTest#createPartitionsRequestAcceptsImmutablePartitionOptionsTestcovers both directions: an immutable list of options is accepted and round-trips, and a list that really does hold anullmap still fails with the intendedIllegalArgumentExceptionand message. It fails with the NPE above on master and passes with this change.API and Format
No. The accepted inputs and the rejection message are unchanged; only a valid input that used to throw the wrong exception now works.
Documentation
No.