Skip to content

Commit

Permalink
Fix TestIndexWriterOnError.testIOError failure. (#13436)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jpountz committed May 29, 2024
1 parent b2fb033 commit c5ea94f
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
package org.apache.lucene.index;

import java.io.IOException;
import java.util.stream.Collectors;
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;

/**
Expand Down Expand Up @@ -76,10 +77,12 @@ synchronized DocValuesProducer getDocValuesProducer(

/** 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).collect(Collectors.toList()),
gen -> {
RefCount<DocValuesProducer> dvp = genDVProducers.get(gen);
assert dvp != null : "gen=" + gen;
dvp.decRef();
});
}
}

0 comments on commit c5ea94f

Please sign in to comment.