You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@opennlp.apache.org by Jeff Zemerick <jz...@apache.org> on 2017/04/16 11:46:40 UTC
closeQuietly() for stream try/catch
In cases of code like this when closing a stream:
finally {
try {
sampleStream.close();
} catch (IOException e) {
// sorry that this can fail
}
}
I thought it might be a bit cleaner looking to replace the empty try/catch
with Apache Commons IO's IOUtils.closeQuietly(). I noticed that the Apache
Commons IO dependency's scope is currently set to <scope>test</scope>. If
you agree that the code change would be cleaner, is there any problem with
changing that dependency to a compile dependency instead of test?
Thanks,
Jeff
Re: closeQuietly() for stream try/catch
Posted by Jeff Zemerick <jz...@apache.org>.
That makes sense. Thanks!
On Apr 16, 2017 8:58 AM, "William Colen" <co...@apache.org> wrote:
We try to avoid external dependencies, including Apache Commons.
Take a look if it is possible to use try-with-resources statement.
Thank you,
William
2017-04-16 8:46 GMT-03:00 Jeff Zemerick <jz...@apache.org>:
> In cases of code like this when closing a stream:
>
> finally {
> try {
> sampleStream.close();
> } catch (IOException e) {
> // sorry that this can fail
> }
> }
>
> I thought it might be a bit cleaner looking to replace the empty try/catch
> with Apache Commons IO's IOUtils.closeQuietly(). I noticed that the Apache
> Commons IO dependency's scope is currently set to <scope>test</scope>. If
> you agree that the code change would be cleaner, is there any problem with
> changing that dependency to a compile dependency instead of test?
>
> Thanks,
> Jeff
>
Re: closeQuietly() for stream try/catch
Posted by William Colen <co...@apache.org>.
We try to avoid external dependencies, including Apache Commons.
Take a look if it is possible to use try-with-resources statement.
Thank you,
William
2017-04-16 8:46 GMT-03:00 Jeff Zemerick <jz...@apache.org>:
> In cases of code like this when closing a stream:
>
> finally {
> try {
> sampleStream.close();
> } catch (IOException e) {
> // sorry that this can fail
> }
> }
>
> I thought it might be a bit cleaner looking to replace the empty try/catch
> with Apache Commons IO's IOUtils.closeQuietly(). I noticed that the Apache
> Commons IO dependency's scope is currently set to <scope>test</scope>. If
> you agree that the code change would be cleaner, is there any problem with
> changing that dependency to a compile dependency instead of test?
>
> Thanks,
> Jeff
>