mikemccand commented on a change in pull request #637: LUCENE-8754: Prevent ConcurrentModificationException in SegmentInfo URL: https://github.com/apache/lucene-solr/pull/637#discussion_r273119818
########## File path: lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50PostingsFormat.java ########## @@ -456,7 +456,11 @@ public String toString() { @Override public FieldsConsumer fieldsConsumer(SegmentWriteState state) throws IOException { PostingsWriterBase postingsWriter = new Lucene50PostingsWriter(state); - state.segmentInfo.putAttribute(MODE_KEY, fstLoadMode.name()); + final String previous = state.segmentInfo.putAttribute(MODE_KEY, fstLoadMode.name()); + if (previous != null && previous.equals(fstLoadMode.name()) == false) { + throw new IllegalStateException("found existing value for " + MODE_KEY + " for segment: " + state.segmentInfo.name + Review comment: It's a little spooky that this method throws exception if you try to set the attribute to a different value than it was set before, but then does leave the new value set in the attributes? ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org