Skip to content

Apache Lucene open-source search software

LUCENE-7710: BlockPackedReader now throws CorruptIndexException if bitsPerValue is out of bounds, not generic IOException

Mike McCandlesscab3aae11dd6
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 5d3a0771656..1d45ab87886 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -178,6 +178,10 @@ Improvements
earlier than regular queries in order to improve cache efficiency.
(Adrien Grand)
+* LUCENE-7710: BlockPackedReader throws CorruptIndexException and includes
+ IndexInput description instead of plain IOException (Mike Drob via
+ Mike McCandless)
+
Optimizations
* LUCENE-7641: Optimized point range queries to compute documents that do not
diff --git a/lucene/core/src/java/org/apache/lucene/util/packed/BlockPackedReader.java b/lucene/core/src/java/org/apache/lucene/util/packed/BlockPackedReader.java
index 82bf93f0f15..986cba75bb2 100644
--- a/lucene/core/src/java/org/apache/lucene/util/packed/BlockPackedReader.java
+++ b/lucene/core/src/java/org/apache/lucene/util/packed/BlockPackedReader.java
@@ -28,6 +28,7 @@ import static org.apache.lucene.util.packed.PackedInts.numBlocks;
import java.io.IOException;
+import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.util.Accountable;
import org.apache.lucene.util.LongValues;
@@ -58,7 +59,7 @@ public final class BlockPackedReader extends LongValues implements Accountable {
final int bitsPerValue = token >>> BPV_SHIFT;
sumBPV += bitsPerValue;
if (bitsPerValue > 64) {
- throw new IOException("Corrupted");
+ throw new CorruptIndexException("Corrupted Block#" + i, in);
}
if ((token & MIN_VALUE_EQUALS_0) == 0) {
if (minValues == null) {