You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by GitBox <gi...@apache.org> on 2019/04/08 06:32:34 UTC

[GitHub] [lucene-solr] jpountz commented on a change in pull request #637: LUCENE-8754: Prevent ConcurrentModificationException in SegmentInfo

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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org