From 3706fbc5b0483a9e455d7c0c5b23df1dcbe4f138 Mon Sep 17 00:00:00 2001 From: Uwe Schindler Date: Tue, 10 Apr 2012 13:50:03 +0000 Subject: [PATCH] Fix ShingleFilter reuse, some minor changes to testcase for speed and consistency git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene3969@1311724 13f79535-47bb-0310-9956-ffa450edef68 --- .../lucene/analysis/shingle/ShingleFilter.java | 2 ++ .../lucene/analysis/core/TestRandomChains.java | 15 +++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/modules/analysis/common/src/java/org/apache/lucene/analysis/shingle/ShingleFilter.java b/modules/analysis/common/src/java/org/apache/lucene/analysis/shingle/ShingleFilter.java index 50e7ab59840..d0b8e055352 100644 --- a/modules/analysis/common/src/java/org/apache/lucene/analysis/shingle/ShingleFilter.java +++ b/modules/analysis/common/src/java/org/apache/lucene/analysis/shingle/ShingleFilter.java @@ -439,6 +439,8 @@ public final class ShingleFilter extends TokenFilter { super.reset(); gramSize.reset(); inputWindow.clear(); + nextInputStreamToken = null; + isNextInputStreamToken = false; numFillerTokensToInsert = 0; isOutputHere = false; noShingleOutput = true; diff --git a/modules/analysis/common/src/test/org/apache/lucene/analysis/core/TestRandomChains.java b/modules/analysis/common/src/test/org/apache/lucene/analysis/core/TestRandomChains.java index 4bdd65b9abb..777f7e7b10a 100644 --- a/modules/analysis/common/src/test/org/apache/lucene/analysis/core/TestRandomChains.java +++ b/modules/analysis/common/src/test/org/apache/lucene/analysis/core/TestRandomChains.java @@ -130,17 +130,17 @@ public class TestRandomChains extends BaseTokenStreamTestCase { if ( // don't waste time with abstract classes or deprecated known-buggy ones Modifier.isAbstract(modifiers) || !Modifier.isPublic(modifiers) - || c.isAnnotationPresent(Deprecated.class) || c.isSynthetic() || c.isAnonymousClass() || c.isMemberClass() || c.isInterface() - || !(Tokenizer.class.isAssignableFrom(c) || TokenFilter.class.isAssignableFrom(c) || CharStream.class.isAssignableFrom(c)) || brokenComponents.contains(c) + || c.isAnnotationPresent(Deprecated.class) + || !(Tokenizer.class.isAssignableFrom(c) || TokenFilter.class.isAssignableFrom(c) || CharStream.class.isAssignableFrom(c)) ) { continue; } for (final Constructor ctor : c.getConstructors()) { - // don't test deprecated ctors, they likely have known bugs: - if (ctor.isAnnotationPresent(Deprecated.class) || ctor.isSynthetic()) { + // don't test synthetic or deprecated ctors, they likely have known bugs: + if (ctor.isSynthetic() || ctor.isAnnotationPresent(Deprecated.class)) { continue; } if (Tokenizer.class.isAssignableFrom(c)) { @@ -258,9 +258,8 @@ public class TestRandomChains extends BaseTokenStreamTestCase { }); put(byte.class, new ArgProducer() { @Override public Object create(Random random) { - byte bytes[] = new byte[1]; - random.nextBytes(bytes); - return Byte.valueOf(bytes[0]); + // this wraps to negative when casting to byte + return Byte.valueOf((byte) random.nextInt(256)); } }); put(byte[].class, new ArgProducer() { @@ -671,7 +670,7 @@ public class TestRandomChains extends BaseTokenStreamTestCase { } static final class CheckThatYouDidntReadAnythingReaderWrapper extends CharFilter { - boolean readSomething; + boolean readSomething = false; CheckThatYouDidntReadAnythingReaderWrapper(Reader in) { super(CharReader.get(in));