From 9e98ec186cb042546bb98172327585f60b17ce2f Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Mon, 9 Apr 2012 20:04:55 +0000 Subject: [PATCH] LUCENE-3969: check that startOffset <= endOffset; comment out sops git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene3969@1311406 13f79535-47bb-0310-9956-ffa450edef68 --- .../lucene/analysis/ValidatingTokenFilter.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) 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); } } }