Copilot commented on code in PR #11884:
URL: https://github.com/apache/ozone/pull/11884#discussion_r4630105914
##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/ECReplicationConfig.java:
##########
@@ -67,6 +84,61 @@ public static String allValuesAsString() {
}
}
+ /**
+ * Same as {@link #ECReplicationConfig(String)}, but returns a shared
instance for a config seen before, up to
+ * {@link #MAX_CACHED_CONFIGS} configs and {@link #MAX_CACHED_STRINGS}
strings.
+ */
+ public static ECReplicationConfig getInstance(String string) {
+ final ECReplicationConfig cached = BY_STRING.get(string);
+ if (cached != null) {
+ return cached;
+ }
+ final ECReplicationConfig config = intern(new ECReplicationConfig(string));
+ // The size check is not atomic with the put, so concurrent callers may
exceed the bound by a few entries.
+ if (BY_STRING.size() < MAX_CACHED_STRINGS) {
+ BY_STRING.putIfAbsent(string, config);
Review Comment:
`BY_STRING` limits entry count but retains each raw spelling indefinitely,
and the parser accepts arbitrarily many leading zeroes in numeric fields.
Through S3's `x-amz-meta-storage-config` header, 256 distinct spellings of one
valid config can retain roughly 15 MB of string contents under the default 64
KiB header limit. Limit the length admitted to `BY_STRING` while continuing to
parse and intern longer inputs.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]