Skip to content

Apache Lucene open-source search software

LUCENE-9356: Make FST throw the correct exception upon incorrect input type.

Adrien Grand38adf09ca2ba
diff --git a/lucene/core/src/java/org/apache/lucene/util/fst/FST.java b/lucene/core/src/java/org/apache/lucene/util/fst/FST.java
index 260e9dab1ae..d092850261c 100644
--- a/lucene/core/src/java/org/apache/lucene/util/fst/FST.java
+++ b/lucene/core/src/java/org/apache/lucene/util/fst/FST.java
@@ -26,6 +26,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import org.apache.lucene.codecs.CodecUtil;
+import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.store.ByteBuffersDataOutput;
import org.apache.lucene.store.DataInput;
import org.apache.lucene.store.DataOutput;
@@ -452,7 +453,7 @@ public final class FST<T> implements Accountable {
inputType = INPUT_TYPE.BYTE4;
break;
default:
- throw new IllegalStateException("invalid input type " + t);
+ throw new CorruptIndexException("invalid input type " + t, in);
}
startNode = in.readVLong();