Skip to content

MINOR: Cleanup Tools Module (1/n) #20091

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from

Conversation

sjhajharia
Copy link
Contributor

@sjhajharia sjhajharia commented Jul 2, 2025

Now that Kafka support Java 17, this PR makes some changes in tools
module. The changes in this PR are limited to only some files. A future
PR(s) shall follow.
The changes mostly include:

  • Collections.emptyList(), Collections.singletonList() and
    Arrays.asList() are replaced with List.of()
  • Collections.emptyMap() and Collections.singletonMap() are replaced
    with Map.of()
  • Collections.singleton() is replaced with Set.of()

Sub modules targeted: tools/src/main

@github-actions github-actions bot added triage PRs from the community tools labels Jul 2, 2025
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 @sjhajharia for this patch, left some comments.

Comment on lines 250 to 251
Set<AccessControlEntry> topicAcls = getAcl(opts, new HashSet<>(List.of(WRITE, DESCRIBE, CREATE)));
Set<AccessControlEntry> transactionalIdAcls = getAcl(opts, new HashSet<>(List.of(WRITE, DESCRIBE)));
Copy link
Collaborator

@m1a2st m1a2st Jul 2, 2025

Choose a reason for hiding this comment

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

Could these properties be made immutable?

Suggested change
Set<AccessControlEntry> topicAcls = getAcl(opts, new HashSet<>(List.of(WRITE, DESCRIBE, CREATE)));
Set<AccessControlEntry> transactionalIdAcls = getAcl(opts, new HashSet<>(List.of(WRITE, DESCRIBE)));
Set<AccessControlEntry> topicAcls = getAcl(opts, Set.of(WRITE, DESCRIBE, CREATE));
Set<AccessControlEntry> transactionalIdAcls = getAcl(opts, Set.of(WRITE, DESCRIBE));

Copy link
Collaborator

Choose a reason for hiding this comment

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

Just a reminder:
Set.of does not guarantee order, so it could make tests flaky or break public interfaces.
Please make sure that replacing it with Set.of() won’t cause any issues.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The original code used new HashSet<>(List.of(...)), so I believe the order was not guaranteed in the previous approach.

@sjhajharia
Copy link
Contributor Author

Thanks @m1a2st and @Yunyung for the initial review.
I have addressed the comments in the following commit.
PTAL when possible. TIA!

@sjhajharia sjhajharia changed the title MINOR: Cleanup Tool Module (1/n) MINOR: Cleanup Tools Module (1/n) Jul 2, 2025
@github-actions github-actions bot removed the triage PRs from the community label Jul 3, 2025
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.

3 participants