Apache Solr open-source search software
For repeatable exceptions, store into cache only if child.tokenStream(fieldName, reader) does not throw an exception
Wolfgang Hoschek06b36cb004ca
diff --git a/contrib/memory/src/java/org/apache/lucene/index/memory/AnalyzerUtil.java b/contrib/memory/src/java/org/apache/lucene/index/memory/AnalyzerUtil.javaindex 8c17694345a..71189aefdb1 100644--- a/contrib/memory/src/java/org/apache/lucene/index/memory/AnalyzerUtil.java+++ b/contrib/memory/src/java/org/apache/lucene/index/memory/AnalyzerUtil.java@@ -237,8 +237,7 @@ public class AnalyzerUtil {final ArrayList tokens = (ArrayList) cache.get(fieldName);if (tokens == null) { // not yet cachedfinal 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 cachedreturn new TokenStream() {