[
https://issues.apache.org/jira/browse/TIKA-1719?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17881014#comment-17881014
]
ASF GitHub Bot commented on TIKA-1719:
--------------------------------------
ldh5574 closed pull request #1945: [TIKA-1719] Refactor parseToString method to
use try-with-resources
URL: https://github.com/apache/tika/pull/1945
> Utilize try-with-resources where it is trivial
> ----------------------------------------------
>
> Key: TIKA-1719
> URL: https://issues.apache.org/jira/browse/TIKA-1719
> Project: Tika
> Issue Type: Improvement
> Components: cli, core, example, gui, packaging, parser, server
> Reporter: Yaniv Kunda
> Assignee: Jukka Zitting
> Priority: Minor
> Labels: easyfix
> Fix For: 1.11
>
> Attachments: TIKA-1719.patch
>
>
> The following type of resource usages:
> {code}
> AutoCloseable resource = ...;
> try {
> // do something with resource
> } finally {
> resource.close();
> }
> {code}
> {code}
> AutoCloseable resource = null;
> try {
> resource = ...;
> // do something with resource
> } finally {
> if (resource != null) {
> resource.close();
> }
> }
> {code}
> and similar constructs can be trivially replaced with Java 7's
> try-with-resource statement:
> {code}
> try (AutoCloseable resource = ...) {
> // do something with resource
> }
> {code}
> This brings more concise code with less chance of causing resource leaks.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)