mirror of https://github.com/apache/lucene.git
For repeatable exceptions, store into cache only if child.tokenStream(fieldName, reader) does not throw an exception
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@479754 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
deb74c1dfb
commit
06b36cb004
|
@ -237,8 +237,7 @@ public class AnalyzerUtil {
|
|||
final ArrayList tokens = (ArrayList) cache.get(fieldName);
|
||||
if (tokens == null) { // not yet cached
|
||||
final ArrayList tokens2 = new ArrayList();
|
||||
cache.put(fieldName, tokens2);
|
||||
return new TokenFilter(child.tokenStream(fieldName, reader)) {
|
||||
TokenStream stream = new TokenFilter(child.tokenStream(fieldName, reader)) {
|
||||
|
||||
public Token next() throws IOException {
|
||||
Token token = input.next(); // from filter super class
|
||||
|
@ -246,6 +245,8 @@ public class AnalyzerUtil {
|
|||
return token;
|
||||
}
|
||||
};
|
||||
cache.put(fieldName, tokens2);
|
||||
return stream;
|
||||
} else { // already cached
|
||||
return new TokenStream() {
|
||||
|
||||
|
|
Loading…
Reference in New Issue