On 24/01/15 15:36, Ian Emmons wrote:
+1 -- Moving to Java 7 should include a comprehensive review of which classes
should become closable to enable try-with-resources.
What would be really great is if you'd look through the codebase and
make suggestions as to where it makes sense.
(we have had some earlier discussions on the subject)
Ideally, the Jena code base should also use try-with-resources internally
wherever that makes sense.
The critical factor is "where it makes sense" such as where the resource
fits the try-with-resources idiom. Many things do not - they are passed
around, not used within a scoped code block.
e.g. QueryExecution - that does fit the paradigm of AutoClosable very
nicely.
Graph does not seem to be to be used in a try-resource fashion.
Note that in some cases extending AutoCloseable might be preferable.
Closeable.close() may only throw IOException, whereas AutoCloseable.close() may
throw Exception.
Yes.
(BTW: wrong closeable - org.apache.jena.atlas.lib.Closeable)
Andy