Skip to content

Apache Lucene open-source search software

fix test failure in TestUTF32ToUTF8 (the random regex-generator generates invalid ranges)

Robert Muirde8177af0093
diff --git a/lucene/src/java/org/apache/lucene/util/automaton/RegExp.java b/lucene/src/java/org/apache/lucene/util/automaton/RegExp.java
index c2a0e32c71a..dec19cb2877 100644
--- a/lucene/src/java/org/apache/lucene/util/automaton/RegExp.java
+++ b/lucene/src/java/org/apache/lucene/util/automaton/RegExp.java
@@ -785,6 +785,8 @@ public class RegExp {
}
static RegExp makeCharRange(int from, int to) {
+ if (from > to)
+ throw new IllegalArgumentException("invalid range: from (" + from + ") cannot be > to (" + to + ")");
RegExp r = new RegExp();
r.kind = Kind.REGEXP_CHAR_RANGE;
r.from = from;