[ https://issues.apache.org/jira/browse/TIKA-1719?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jukka Zitting resolved TIKA-1719. --------------------------------- Resolution: Fixed Assignee: Jukka Zitting Committed in revision 1700195. Thanks a lot for this patch! I remember writing many of these blocks earlier and wishing that try-with-resources was already available for us... Note that I broke some of the lines to fit within 80 columns. We aren't too consistent in applying that convention, but it's a good thing to strive for. Also, the review was complicated a bit by the extra whitespace changes included in the patch. All of those were changes in the right direction, so thanks! > 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 (v6.3.4#6332)