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,11 +41,9 @@ public final class HtmlStripProcessor extends AbstractStringProcessor<String> {
return value;
}
HTMLStripCharFilter filter = new HTMLStripCharFilter(new StringReader(value));
StringBuilder builder = new StringBuilder();
try (HTMLStripCharFilter filter = new HTMLStripCharFilter(new StringReader(value))) {
int ch;
try {
while ((ch = filter.read()) != -1) {
builder.append((char) ch);
}