mirror of
https://github.com/apache/lucene.git
synced 2025-02-28 21:39:25 +00:00
SOLR-10351: Add try-with-resources clause around TokenStream
This commit is contained in:
parent
65b4530fb3
commit
e872dc7913
@ -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…
x
Reference in New Issue
Block a user