diff --git a/lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java index 88c668f4dd9..2ee380e3478 100644 --- a/lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java +++ b/lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java @@ -1475,7 +1475,9 @@ public abstract class BasePostingsFormatTestCase extends LuceneTestCase { } // Also test seeking the TermsEnum: - for(String term : termFreqs.keySet()) { + // must make copy because this very code sometimes makes puts while iterating?! + Set copy = new HashSet(termFreqs.keySet()); + for(String term : copy) { if (termsEnum.seekExact(new BytesRef(term))) { if (random().nextBoolean()) { docs = termsEnum.docs(null, docs, DocsEnum.FLAG_FREQS);