MINOR: Replace Collections factory methods with Java 11+ equivalents in clients#22060
MINOR: Replace Collections factory methods with Java 11+ equivalents in clients#22060see-quick wants to merge 1 commit intoapache:trunkfrom
Conversation
…in clients Signed-off-by: see-quick <maros.orsak159@gmail.com>
clolov
left a comment
There was a problem hiding this comment.
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 😊
| public MetricKey(String name, Map<String, String> tags) { | ||
| this.name = Objects.requireNonNull(name); | ||
| this.tags = tags != null ? Collections.unmodifiableMap(tags) : Collections.emptyMap(); | ||
| this.tags = tags != null ? Collections.unmodifiableMap(tags) : Map.of(); |
There was a problem hiding this comment.
Collections.unmodifiableMap => Map.copyOf?
| exporting the metrics to the telemetry backend. | ||
| */ | ||
| private static final Set<String> EXCLUDE_LABELS = Collections.singleton("client_id"); | ||
| private static final Set<String> EXCLUDE_LABELS = Set.of("client_id"); |
There was a problem hiding this comment.
There is one more entry in this file of Collections.unmodifiableList which you can try to change to List.copyOf? If this works you can also remove the import of Collections 😊
| 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()); |
There was a problem hiding this comment.
Similarly, there is a usage of Collections.unmodifiableMap which you can try to modify (put intended) and then remove the whole of Collections.
| String scopeClaimValue = claim(scopeClaimName, String.class); | ||
| if (Utils.isBlank(scopeClaimValue)) | ||
| return Collections.emptySet(); | ||
| return Set.of(); |
There was a problem hiding this comment.
Similar comment to other comments 😊
| @Override | ||
| public Set<String> reconfigurableConfigs() { | ||
| return securityProtocol == SecurityProtocol.SASL_SSL ? SslConfigs.RECONFIGURABLE_CONFIGS : Collections.emptySet(); | ||
| return securityProtocol == SecurityProtocol.SASL_SSL ? SslConfigs.RECONFIGURABLE_CONFIGS : Set.of(); |
|
Could you also rebase and resolve the conflict so that tests can run? |
This is the 4th part of improving replace collections factory methods with its Java 11 equivalents in the clients module.