diff --git a/lucene/core/src/java/org/apache/lucene/analysis/CharReader.java b/lucene/core/src/java/org/apache/lucene/analysis/CharReader.java index a83637f455c..9cb31d5958c 100644 --- a/lucene/core/src/java/org/apache/lucene/analysis/CharReader.java +++ b/lucene/core/src/java/org/apache/lucene/analysis/CharReader.java @@ -54,6 +54,11 @@ public final class CharReader extends CharStream { return input.read(cbuf, off, len); } + @Override + public int read() throws IOException { + return input.read(); + } + @Override public boolean markSupported(){ return input.markSupported(); diff --git a/modules/analysis/common/src/java/org/apache/lucene/analysis/charfilter/CharFilter.java b/modules/analysis/common/src/java/org/apache/lucene/analysis/charfilter/CharFilter.java index 8687e93cef0..ea73ce7cd48 100644 --- a/modules/analysis/common/src/java/org/apache/lucene/analysis/charfilter/CharFilter.java +++ b/modules/analysis/common/src/java/org/apache/lucene/analysis/charfilter/CharFilter.java @@ -65,6 +65,11 @@ public abstract class CharFilter extends CharStream { return input.read(cbuf, off, len); } + @Override + public int read() throws IOException { + return input.read(); + } + @Override public boolean markSupported(){ return input.markSupported(); 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 fdd5aadb123..05b40a765af 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 @@ -756,77 +756,32 @@ public class TestRandomChains extends BaseTokenStreamTestCase { } } - // wants charfilter to be a filterreader... - // do *NOT* refactor me to be a charfilter: LUCENE-3990 - static class CheckThatYouDidntReadAnythingReaderWrapper extends CharStream { - boolean readSomething; - CharStream in; + static final class CheckThatYouDidntReadAnythingReaderWrapper extends CharFilter { + boolean readSomething = false; CheckThatYouDidntReadAnythingReaderWrapper(Reader in) { - this.in = CharReader.get(in); - } - - @Override - public int correctOffset(int currentOff) { - return in.correctOffset(currentOff); - } - - @Override - public void close() throws IOException { - in.close(); + super(CharReader.get(in)); } @Override public int read(char[] cbuf, int off, int len) throws IOException { readSomething = true; - return in.read(cbuf, off, len); + return super.read(cbuf, off, len); } @Override public int read() throws IOException { readSomething = true; - return in.read(); - } - - @Override - public int read(CharBuffer target) throws IOException { - readSomething = true; - return in.read(target); - } - - @Override - public void mark(int readAheadLimit) throws IOException { - in.mark(readAheadLimit); - } - - @Override - public boolean markSupported() { - return in.markSupported(); - } - - @Override - public int read(char[] cbuf) throws IOException { - readSomething = true; - return in.read(cbuf); - } - - @Override - public boolean ready() throws IOException { - return in.ready(); - } - - @Override - public void reset() throws IOException { - in.reset(); + return super.read(); } @Override public long skip(long n) throws IOException { readSomething = true; - return in.skip(n); + return super.skip(n); } } - + static class TokenizerSpec { Tokenizer tokenizer; String toString;