blerer commented on code in PR #15457:
URL: https://github.com/apache/lucene/pull/15457#discussion_r2578263716


##########
lucene/core/src/java/org/apache/lucene/index/FieldInfo.java:
##########
@@ -675,7 +674,7 @@ public synchronized String putAttribute(String key, String 
value) {
     String oldValue = newMap.put(key, value);
     // This needs to be thread-safe as multiple threads may be updating 
(different) attributes
     // concurrently due to concurrent merging.
-    attributes = Collections.unmodifiableMap(newMap);
+    attributes = Map.copyOf(newMap);

Review Comment:
   The idea was to align the code of `FieldInfo` with the one of `SegmentInfo`. 
Currently `SegmentInfo` is using `ImmutableCollections.AbstractImmutableMap` 
(through `Map.copyOf`) whereas `FieldInfo` is using `UnmodifiableMap` (through 
`Collections.unmodifiable`). Originally `SegmentInfo` was doing some defensive 
copies using `Collections.unmodifiableMap(new 
HashMap<>(Objects.requireNonNull(diagnostics)));` but they have been replaced 
by `Maps.copyOf` in [#649](https://github.com/apache/lucene/commit/3a6f2f75)



-- 
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]

Reply via email to