Yaniv Kunda created TIKA-1719:
---------------------------------
Summary: 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
Priority: Minor
Fix For: 1.11
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)