Skip to content

Commit c5ea94f

Browse files
committed
Fix TestIndexWriterOnError.testIOError failure. (#13436)
Pull request #13406 inadvertly broke Lucene's handling of tragic exceptions by stopping after the first `DocValuesProducer` whose `close()` calls throws an exception, instead of keeping calling `close()` on further producers in the list. This moves back to the previous behavior. Closes #13434
1 parent b2fb033 commit c5ea94f

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lucene/core/src/java/org/apache/lucene/index/SegmentDocValues.java

+9-6
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@
1717
package org.apache.lucene.index;
1818

1919
import java.io.IOException;
20+
import java.util.stream.Collectors;
2021
import org.apache.lucene.codecs.DocValuesFormat;
2122
import org.apache.lucene.codecs.DocValuesProducer;
2223
import org.apache.lucene.internal.hppc.LongArrayList;
23-
import org.apache.lucene.internal.hppc.LongCursor;
2424
import org.apache.lucene.internal.hppc.LongObjectHashMap;
2525
import org.apache.lucene.store.Directory;
2626
import org.apache.lucene.store.IOContext;
27+
import org.apache.lucene.util.IOUtils;
2728
import org.apache.lucene.util.RefCount;
2829

2930
/**
@@ -76,10 +77,12 @@ synchronized DocValuesProducer getDocValuesProducer(
7677

7778
/** Decrement the reference count of the given {@link DocValuesProducer} generations. */
7879
synchronized void decRef(LongArrayList dvProducersGens) throws IOException {
79-
for (LongCursor gen : dvProducersGens) {
80-
RefCount<DocValuesProducer> dvp = genDVProducers.get(gen.value);
81-
assert dvp != null : "gen=" + gen;
82-
dvp.decRef();
83-
}
80+
IOUtils.applyToAll(
81+
dvProducersGens.stream().mapToObj(Long::valueOf).collect(Collectors.toList()),
82+
gen -> {
83+
RefCount<DocValuesProducer> dvp = genDVProducers.get(gen);
84+
assert dvp != null : "gen=" + gen;
85+
dvp.decRef();
86+
});
8487
}
8588
}

0 commit comments

Comments
 (0)