Skip to content

MINOR: Replace Collections factory methods with Java 11+ equivalents in clients#22060

Open
see-quick wants to merge 2 commits intoapache:trunkfrom
see-quick:MINOR-refactor-from-jdk8-to-jdk11-part4
Open

MINOR: Replace Collections factory methods with Java 11+ equivalents in clients#22060
see-quick wants to merge 2 commits intoapache:trunkfrom
see-quick:MINOR-refactor-from-jdk8-to-jdk11-part4

Conversation

@see-quick
Copy link
Copy Markdown
Contributor

This is the 4th part of improving replace collections factory methods with its Java 11 equivalents in the clients module.

@github-actions github-actions bot added clients small Small PRs triage PRs from the community labels Apr 14, 2026
Copy link
Copy Markdown
Contributor

@nileshkumar3 nileshkumar3 left a comment

Choose a reason for hiding this comment

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

LGTM!

@github-actions github-actions bot removed the triage PRs from the community label Apr 15, 2026
Copy link
Copy Markdown
Contributor

@clolov clolov left a comment

Choose a reason for hiding this comment

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

There are a few files where I believe you can fully clean up the usage of Collections, but let me know if I am missing something obvious! Thank you for persevering with this 😊

Comment thread clients/src/main/java/org/apache/kafka/common/telemetry/internals/MetricKey.java Outdated
private List<String> requiredScope() {
String requiredSpaceDelimitedScope = option(REQUIRED_SCOPE_OPTION);
return Utils.isBlank(requiredSpaceDelimitedScope) ? Collections.emptyList() : OAuthBearerScopeUtils.parseScope(requiredSpaceDelimitedScope.trim());
return Utils.isBlank(requiredSpaceDelimitedScope) ? List.of() : OAuthBearerScopeUtils.parseScope(requiredSpaceDelimitedScope.trim());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Similarly, there is a usage of Collections.unmodifiableMap which you can try to modify (put intended) and then remove the whole of Collections.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmm I am not sure here I can modify it into Map.copy(...)

this.moduleOptions = Collections
                .unmodifiableMap((Map<String, String>) jaasConfigEntries.get(0).getOptions());

as I think .getOptions() could return NPE.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I will do another check through the codebase. I believe I understand what you mean i.e. not that the map itself could be null, but that a value in the options could be null. Somehow I doubt that we would create a configuration with a key pointing to null (hence wanting to check how/where we use this) and if we don't, I would prefer that we error on the map creation anyway.

@clolov
Copy link
Copy Markdown
Contributor

clolov commented Apr 15, 2026

Could you also rebase and resolve the conflict so that tests can run?

…in clients

Signed-off-by: see-quick <maros.orsak159@gmail.com>
Signed-off-by: see-quick <maros.orsak159@gmail.com>
@see-quick see-quick force-pushed the MINOR-refactor-from-jdk8-to-jdk11-part4 branch from 6a3e34b to 32199b4 Compare April 20, 2026 09:21
@github-actions github-actions bot removed the small Small PRs label Apr 20, 2026
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