Ensure auto close of HTMLStripCharFilter in HtmlStripProcessor

The HtmlStripProcessor did not use a try-with resources block to ensure
that the used HTMLStripCharFilter is closed.
This commit is contained in:
Dan Hermann 2020-05-01 17:31:53 -05:00 committed by GitHub
parent d53c941c41
commit 2061652988
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 5 deletions

View File

@ -41,13 +41,11 @@ public final class HtmlStripProcessor extends AbstractStringProcessor<String> {
return value; return value;
} }
HTMLStripCharFilter filter = new HTMLStripCharFilter(new StringReader(value));
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
int ch; try (HTMLStripCharFilter filter = new HTMLStripCharFilter(new StringReader(value))) {
try { int ch;
while ((ch = filter.read()) != -1) { while ((ch = filter.read()) != -1) {
builder.append((char)ch); builder.append((char) ch);
} }
} catch (IOException e) { } catch (IOException e) {
throw new ElasticsearchException(e); throw new ElasticsearchException(e);