KAFKA-19833: Reduce code duplication in nullable protocol types#21019
Merged
junrao merged 9 commits intoapache:trunkfrom Feb 10, 2026
Merged
KAFKA-19833: Reduce code duplication in nullable protocol types#21019junrao merged 9 commits intoapache:trunkfrom
junrao merged 9 commits intoapache:trunkfrom
Conversation
Collaborator
Author
|
A label of 'needs-attention' was automatically added to this PR in order to raise the |
junrao
reviewed
Dec 12, 2025
junrao
reviewed
Feb 2, 2026
| * Represents a type for an array of a particular type | ||
| */ | ||
| public class ArrayOf extends DocumentedType { | ||
|
|
Contributor
There was a problem hiding this comment.
Since we kept the BYTES implementation, we already have different patterns for implementing nullable types. So, instead of unifying the pattern, the goal should probably be to avoid code duplication. Since there is no code duplication in the existing ArrayOf, we can just keep it as it is. Ditto for CompactArraryOf.
# Conflicts: # clients/src/main/java/org/apache/kafka/common/protocol/types/Type.java # transaction-coordinator/src/test/java/org/apache/kafka/coordinator/transaction/TransactionLogTest.java
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.
Nullable types (
NULLABLE_STRING,NULLABLE_BYTES,NULLABLE_RECORDS,etc.) in
Type.javaduplicate most of the read/write/sizeOf logic fromtheir non-nullable counterparts.
This PR reduces the duplication by:
stringRead()andbytesRead()helper methodsfor common read logic
write()/read()/sizeOf()to thecorresponding non-nullable type after null checks