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
This commit is contained in:
Adrien Grand 2024-05-29 22:08:10 +02:00 committed by GitHub
parent 9a3dbd5dd7
commit 750a7c4d3b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 6 deletions

View File

@ -20,10 +20,10 @@ import java.io.IOException;
import org.apache.lucene.codecs.DocValuesFormat;
import org.apache.lucene.codecs.DocValuesProducer;
import org.apache.lucene.internal.hppc.LongArrayList;
import org.apache.lucene.internal.hppc.LongCursor;
import org.apache.lucene.internal.hppc.LongObjectHashMap;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.RefCount;
/**
@ -76,10 +76,12 @@ final class SegmentDocValues {
/** Decrement the reference count of the given {@link DocValuesProducer} generations. */
synchronized void decRef(LongArrayList dvProducersGens) throws IOException {
for (LongCursor gen : dvProducersGens) {
RefCount<DocValuesProducer> dvp = genDVProducers.get(gen.value);
assert dvp != null : "gen=" + gen;
dvp.decRef();
}
IOUtils.applyToAll(
dvProducersGens.stream().mapToObj(Long::valueOf).toList(),
gen -> {
RefCount<DocValuesProducer> dvp = genDVProducers.get(gen);
assert dvp != null : "gen=" + gen;
dvp.decRef();
});
}
}