don't throw NPE if someone consumes us wrong, also null out random on close to be pickier

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1525719 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2013-09-23 22:25:17 +00:00
parent dabeab3b38
commit 764c248064
1 changed files with 9 additions and 0 deletions

View File

@ -104,11 +104,20 @@ public final class MockGraphTokenFilter extends LookaheadTokenFilter<LookaheadTo
this.random = new Random(seed);
}
@Override
public void close() throws IOException {
super.close();
this.random = null;
}
@Override
public boolean incrementToken() throws IOException {
if (DEBUG) {
System.out.println("MockGraphTF.incr inputPos=" + inputPos + " outputPos=" + outputPos);
}
if (random == null) {
throw new IllegalStateException("incrementToken called in wrong state!");
}
return nextToken();
}
}