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

Julian Hyde commented on CALCITE-1008:
--------------------------------------

I think that would be dangerous. I tried converting 
[https://github.com/apache/calcite/blob/master/splunk/src/main/java/org/apache/calcite/adapter/splunk/search/SplunkConnectionImpl.java#L120](SplunkConnectionImpl.connect)
 to use try-with-resources and realized that I was subtly changing the behavior 
BufferedReader.close threw an exception. I don't want to introduce bugs, so I 
backed out that particular change.

The code change for this bug is very small and (I believe) safe. But because it 
widens Closeable to AutoCloseable it gives new opportunities to use 
try-with-resources.

But yes, we should encourage people to use try-with-resources in new code, and 
convert old code when it makes sense.

> Replace Closeable with AutoCloseable
> ------------------------------------
>
>                 Key: CALCITE-1008
>                 URL: https://issues.apache.org/jira/browse/CALCITE-1008
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Julian Hyde
>            Assignee: Julian Hyde
>
> Now Calcite no longer supports JDK 1.6 we can use AutoCloseable if we want 
> to. It is more appropriate interface for releasing resources on close because 
> it is not so tightly associated with I/O. (Closeable.close throws 
> IOException.) Most, if not all, uses of Closeable in Calcite should instead 
> use AutoCloseable.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to