LUCENE-3990: Fix CharFilter to delegate correctly (and prevent CharFilter slowdown! - maybe backport!!!)

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1326512 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2012-04-16 07:01:56 +00:00
parent 2b07186492
commit 9252239fee
3 changed files with 17 additions and 52 deletions

View File

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

View File

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

View File

@ -756,74 +756,29 @@ 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);
}
}