Gimini-3 commented on code in PR #23128:
URL: https://github.com/apache/kafka/pull/23128#discussion_r4028094216
##########
metadata/src/main/java/org/apache/kafka/image/ScramImage.java:
##########
@@ -46,7 +46,10 @@ public record ScramImage(Map<ScramMechanism, Map<String,
ScramCredentialData>> m
public static final ScramImage EMPTY = new ScramImage(Map.of());
public ScramImage {
- mechanisms = Collections.unmodifiableMap(mechanisms);
+ Map<ScramMechanism, Map<String, ScramCredentialData>> copiedMechanisms
= new HashMap<>();
+ mechanisms.forEach((mechanism, credentials) ->
+ copiedMechanisms.put(mechanism, Collections.unmodifiableMap(new
HashMap<>(credentials))));
Review Comment:
Thanks, @kevin-wu24. I applied the suggested implementation in `fbe387f5c2`:
the outer map is pre-sized and copied, while each nested map is wrapped
directly with `Collections.unmodifiableMap` without copying its contents. I
also updated the PR title and description to describe unmodifiable maps rather
than immutable snapshots.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]