jpountz commented on a change in pull request #637: LUCENE-8754: Prevent 
ConcurrentModificationException in SegmentInfo
URL: https://github.com/apache/lucene-solr/pull/637#discussion_r272899879
 
 

 ##########
 File path: lucene/core/src/java/org/apache/lucene/index/SegmentInfo.java
 ##########
 @@ -111,12 +112,12 @@ public SegmentInfo(Directory dir, Version version, 
Version minVersion, String na
     this.maxDoc = maxDoc;
     this.isCompoundFile = isCompoundFile;
     this.codec = codec;
-    this.diagnostics = Objects.requireNonNull(diagnostics);
+    this.diagnostics = Collections.unmodifiableMap(new 
HashMap<>(Objects.requireNonNull(diagnostics)));
     this.id = id;
     if (id.length != StringHelper.ID_LENGTH) {
       throw new IllegalArgumentException("invalid id: " + Arrays.toString(id));
     }
-    this.attributes = Objects.requireNonNull(attributes);
+    this.attributes = Collections.unmodifiableMap(new 
HashMap<>(Objects.requireNonNull(attributes)));
 
 Review comment:
   Nit: now that we are copying the input attributes, we should change the few 
call sites that pass a `new HashMap<>()` as attributes to pass a 
`Collections.emptyMap()` instead?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to