Skip to content

MINOR: Cleanup Core Module- Scala Modules (3/n) #19804

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 3 commits into
base: trunk
Choose a base branch
from

Conversation

sjhajharia
Copy link
Contributor

Now that Kafka Brokers support Java 17, this PR makes some changes in
core module. The changes in this PR are limited to only some Scala files
in the Core module's tests. 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()

To be clear, the directories being targeted in this PR from unit.kafka module:

  • admin
  • cluster
  • coordinator
  • docker
  • integration
  • metrics

@github-actions github-actions bot added triage PRs from the community core Kafka Broker tests Test fixes (including flaky tests) labels May 24, 2025
@m1a2st
Copy link
Collaborator

m1a2st commented May 28, 2025

Thanks @sjhajharia for this patch, please check the fail tests

Copy link
Contributor

@frankvicky frankvicky left a comment

Choose a reason for hiding this comment

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

@sjhajharia: Thanks for the clean up.
I have a few comments.

@@ -364,7 +364,7 @@ abstract class KafkaServerTestHarness extends QuorumTestHarness {
def changeClientIdConfig(sanitizedClientId: String, configs: Properties): Unit = {
Using.resource(createAdminClient(brokers, listenerName)) {
admin => {
admin.alterClientQuotas(Collections.singleton(
admin.alterClientQuotas(util.Set.of(
new ClientQuotaAlteration(
new ClientQuotaEntity(Map(ClientQuotaEntity.CLIENT_ID -> (if (sanitizedClientId == "<default>") null else sanitizedClientId)).asJava),
Copy link
Contributor

Choose a reason for hiding this comment

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

Could it be java.util.Map.of ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. We can't use that here because of the if block. In case of "' it ends up with null with Map.of wouldn't allow.

@sjhajharia
Copy link
Contributor Author

Thanks @frankvicky for the review. I have addressed all the comments.

@sjhajharia sjhajharia requested a review from frankvicky May 29, 2025 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-approved core Kafka Broker tests Test fixes (including flaky tests) triage PRs from the community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants