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:
Wolfgang Hoschek 2006-11-27 20:34:45 +00:00
parent deb74c1dfb
commit 06b36cb004
1 changed files with 3 additions and 2 deletions

View File

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