SOLR-822: avoid ClassCastException when CharStreamAware*TokenizerFactory is used without CharFilter

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@758137 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Koji Sekiguchi 2009-03-25 03:34:34 +00:00
parent 96a3f027ce
commit 82965b7fa1
2 changed files with 10 additions and 2 deletions

View File

@ -30,6 +30,10 @@ import org.apache.lucene.analysis.TokenStream;
public class CharStreamAwareCJKTokenizerFactory extends BaseTokenizerFactory {
public CharStreamAwareCJKTokenizer create(Reader input) {
return new CharStreamAwareCJKTokenizer( (CharStream)input );
return new CharStreamAwareCJKTokenizer(
input instanceof CharStream ?
(CharStream)input :
new CharReader(input)
);
}
}

View File

@ -30,6 +30,10 @@ import org.apache.lucene.analysis.TokenStream;
public class CharStreamAwareWhitespaceTokenizerFactory extends BaseTokenizerFactory {
public CharStreamAwareWhitespaceTokenizer create(Reader input) {
return new CharStreamAwareWhitespaceTokenizer( (CharStream)input );
return new CharStreamAwareWhitespaceTokenizer(
input instanceof CharStream ?
(CharStream)input :
new CharReader(input)
);
}
}