Skip to content

Conversation

mimaison
Copy link
Member

@mimaison mimaison commented Jul 3, 2025

  • Use record where possible
  • Use enhanced switch
  • Tweak a bunch of assertions

Reviewers: Yung [email protected], TengYao Chi
[email protected], Ken Huang [email protected], Dongnuo Lyu
[email protected], PoAn Yang [email protected]

Copy link
Collaborator

@Yunyung Yunyung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, LGTM. Left one minor comment.

@@ -36,7 +36,7 @@
public record TopologyMetadata(MetadataImage metadataImage, SortedMap<String, ConfiguredSubtopology> subtopologyMap) implements TopologyDescriber {

public TopologyMetadata {
metadataImage = Objects.requireNonNull(metadataImage);
Objects.requireNonNull(metadataImage);
subtopologyMap = Objects.requireNonNull(Collections.unmodifiableSortedMap(subtopologyMap));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick. The same applies to line36 in StreamsGroupHeartbeatResult.java.

Suggested change
subtopologyMap = Objects.requireNonNull(Collections.unmodifiableSortedMap(subtopologyMap));
subtopologyMap = Collections.unmodifiableSortedMap(Objects.requireNonNull(subtopologyMap));

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand your comment. Can you clarify what you mean?

Copy link
Collaborator

@Yunyung Yunyung Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the passed subtopologyMap is null
Current: Collections.unmodifiableSortedMap throws NPE (so Objects.requireNonNull never takes effect).
After: Objects.requireNonNull throws NPE.

Also, this results in a different stack trace if NPE.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, done

Copy link
Collaborator

@m1a2st m1a2st left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mimaison for this patch, a little comment

Comment on lines 50 to 56
/**
* @return The base timestamp.
*/
@Override
public Function<OffsetAndMetadata, Long> baseTimestamp() {
return this.baseTimestamp;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The override method also can be removed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, done

this.partitions = Objects.requireNonNull(partitions);
public record MemberAssignmentImpl(Map<Uuid, Set<Integer>> partitions) implements MemberAssignment {
public MemberAssignmentImpl {
Objects.requireNonNull(partitions);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we wrap the partitions with Collections.unmodifiableMap?
This could ensure the consistency of hashCode.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup I added that

Copy link
Member

@FrankYang0529 FrankYang0529 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -219,7 +219,7 @@ public static Map<Uuid, Set<Integer>> assignmentFromTopicPartitions(
) {
return topicPartitionsList.stream().collect(Collectors.toMap(
ConsumerGroupCurrentMemberAssignmentValue.TopicPartitions::topicId,
topicPartitions -> Collections.unmodifiableSet(new HashSet<>(topicPartitions.partitions()))));
topicPartitions -> Collections.unmodifiableSet(new HashSet<>(topicPartitions.partitions()))));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Do we need the extra indentation? since L221 and 222 are two parameters of Collectors.toMap

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@mimaison mimaison force-pushed the cleanups-coordinator branch from 7c15597 to bd91f38 Compare July 30, 2025 14:16
@mimaison
Copy link
Member Author

Thanks @FrankYang0529 for the review. I pushed an update addressing the issues you found.

Copy link
Member

@FrankYang0529 FrankYang0529 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the patch.

@FrankYang0529 FrankYang0529 merged commit fd9b551 into apache:trunk Jul 31, 2025
26 checks passed
@mimaison mimaison deleted the cleanups-coordinator branch July 31, 2025 08:41
public final String key;
public final CoordinatorResult<Void, T> result;

public record ExecutorResult<T>(String key, CoordinatorResult<Void, T> result) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Pankraz76
Copy link

Well done thanks. Kind of hard to review as its entangled, but thats how its done, no offence given.

Its not ensured that these patterns wont (re)occur anywhere else, making the whole storing ongoing.

Rewrite has the ability to automate this:

Hope this helps, thanks.

airlock-confluentinc bot pushed a commit to confluentinc/kafka that referenced this pull request Aug 6, 2025
- Use `record` where possible
- Use enhanced `switch`
- Tweak a bunch of assertions

Reviewers: Yung <[email protected]>, TengYao Chi
 <[email protected]>, Ken Huang <[email protected]>, Dongnuo Lyu
 <[email protected]>, PoAn Yang <[email protected]>
k-apol pushed a commit to k-apol/kafka that referenced this pull request Aug 8, 2025
- Use `record` where possible
- Use enhanced `switch`
- Tweak a bunch of assertions

Reviewers: Yung <[email protected]>, TengYao Chi
 <[email protected]>, Ken Huang <[email protected]>, Dongnuo Lyu
 <[email protected]>, PoAn Yang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants