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));