diff --git a/lucene/test-framework/src/java/org/apache/lucene/analysis/ValidatingTokenFilter.java b/lucene/test-framework/src/java/org/apache/lucene/analysis/ValidatingTokenFilter.java index fe98feb3116..984f8b5b696 100644 --- a/lucene/test-framework/src/java/org/apache/lucene/analysis/ValidatingTokenFilter.java +++ b/lucene/test-framework/src/java/org/apache/lucene/analysis/ValidatingTokenFilter.java @@ -82,19 +82,23 @@ public final class ValidatingTokenFilter extends TokenFilter { final int startOffset = offsetAtt.startOffset(); final int endOffset = offsetAtt.endOffset(); + if (endOffset < startOffset) { + throw new IllegalStateException(name + ": startOffset=" + startOffset + " is > endOffset=" + endOffset + " pos=" + pos + "; token=" + termAtt); + } + final int posLen = posLenAtt == null ? 1 : posLenAtt.getPositionLength(); if (!posToStartOffset.containsKey(pos)) { // First time we've seen a token leaving from this position: posToStartOffset.put(pos, startOffset); - System.out.println(" + s " + pos + " -> " + startOffset); + //System.out.println(" + s " + pos + " -> " + startOffset); } else { // We've seen a token leaving from this position // before; verify the startOffset is the same: - System.out.println(" + vs " + pos + " -> " + startOffset); + //System.out.println(" + vs " + pos + " -> " + startOffset); final int oldStartOffset = posToStartOffset.get(pos); if (oldStartOffset != startOffset) { - throw new IllegalStateException(name + ": inconsistent startOffset as pos=" + pos + ": " + oldStartOffset + " vs " + startOffset + "; token=" + termAtt); + throw new IllegalStateException(name + ": inconsistent startOffset at pos=" + pos + ": " + oldStartOffset + " vs " + startOffset + "; token=" + termAtt); } } @@ -103,14 +107,14 @@ public final class ValidatingTokenFilter extends TokenFilter { if (!posToEndOffset.containsKey(endPos)) { // First time we've seen a token arriving to this position: posToEndOffset.put(endPos, endOffset); - System.out.println(" + e " + endPos + " -> " + endOffset); + //System.out.println(" + e " + endPos + " -> " + endOffset); } else { // We've seen a token arriving to this position // before; verify the endOffset is the same: - System.out.println(" + ve " + endPos + " -> " + endOffset); + //System.out.println(" + ve " + endPos + " -> " + endOffset); final int oldEndOffset = posToEndOffset.get(endPos); if (oldEndOffset != endOffset) { - throw new IllegalStateException(name + ": inconsistent endOffset as pos=" + endPos + ": " + oldEndOffset + " vs " + endOffset + "; token=" + termAtt); + throw new IllegalStateException(name + ": inconsistent endOffset at pos=" + endPos + ": " + oldEndOffset + " vs " + endOffset + "; token=" + termAtt); } } }