[ 
https://issues.apache.org/jira/browse/TIKA-1719?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17881023#comment-17881023
 ] 

ASF GitHub Bot commented on TIKA-1719:
--------------------------------------

ldh5574 opened a new pull request, #1946:
URL: https://github.com/apache/tika/pull/1946

   Changes made:
   try-with-resources is used to automatically handle closing the InputStream, 
ensuring that it is always closed properly without the need for a finally block.




> 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)

Reply via email to