mirror of https://github.com/apache/lucene.git
SOLR-10351: Add try-with-resources clause around TokenStream
This commit is contained in:
parent
5ee18c8ab5
commit
4dd785e5ef
|
@ -81,17 +81,16 @@ public class AnalyzeEvaluator extends SimpleEvaluator {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
TokenStream tokenStream = analyzer.tokenStream(analyzerField, value);
|
|
||||||
CharTermAttribute termAtt = tokenStream.getAttribute(CharTermAttribute.class);
|
|
||||||
tokenStream.reset();
|
|
||||||
List<String> tokens = new ArrayList();
|
List<String> tokens = new ArrayList();
|
||||||
while (tokenStream.incrementToken()) {
|
|
||||||
tokens.add(termAtt.toString());
|
try(TokenStream tokenStream = analyzer.tokenStream(analyzerField, value)) {
|
||||||
|
CharTermAttribute termAtt = tokenStream.getAttribute(CharTermAttribute.class);
|
||||||
|
tokenStream.reset();
|
||||||
|
while (tokenStream.incrementToken()) {
|
||||||
|
tokens.add(termAtt.toString());
|
||||||
|
}
|
||||||
|
tokenStream.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
tokenStream.end();
|
|
||||||
tokenStream.close();
|
|
||||||
|
|
||||||
return tokens;
|
return tokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue