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

ASF GitHub Bot commented on GROOVY-8251:
----------------------------------------

GitHub user jwagenleitner opened a pull request:

    https://github.com/apache/groovy/pull/572

    GROOVY-8251: Implement withCloseable on AutoCloseable

    `NioGroovyMethods.withAutoCloseable` was added for 2.5.0 as part of 
[GROOVY-7572](https://issues.apache.org/jira/browse/GROOVY-7572).  It appears 
it was originally placed here because at the time Java 6 was still used, but 
now 2.5.0 is 7+.
    
    First commit proposes moving the method (as-is) into the core 
`IOGroovyMethods` class.  This is where the 
`withCloseable(java.io.Closeable...)` method is, so also part of this change is 
moving the tests for it from NIO to core.  Since 2.5.0 is not been officially 
released I don't think there is a need to deprecate or worry about binary 
compatibility for the `withAutoCloseable` method.
    
    Second commit proposes to rename the new but unreleased method from 
`withAutoCloseable` to `withCloseable` to match the existing method on 
`java.io.Closeable`.  See discussion on 
[GROOVY-8251](https://issues.apache.org/jira/browse/GROOVY-8251).

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/jwagenleitner/groovy 8251-AutoCloseable

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/groovy/pull/572.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #572
    
----
commit 912200153193849fc35a09a053898d46c7f1dacd
Author: John Wagenleitner <[email protected]>
Date:   2017-07-09T00:22:36Z

    GROOVY-8251: Implement withCloseable on AutoCloseable
    
    Relocate withAutoCloseable from NIO subproject to core. Since
    AutoCloseable is not an NIO related class and release 2.5.0
    will target Java 7, the method should be available as part
    of core.
    
    Relocated withCloseable tests to core since that method
    is deprecated in the NIO module.

commit 261bc174980da8d6b6f4cdb54b8f0ab98c64c4fd
Author: John Wagenleitner <[email protected]>
Date:   2017-07-09T01:13:48Z

    GROOVY-8251: rename withAutoCloseable to withCloseable

----


> Implement withCloseable on AutoCloseable
> ----------------------------------------
>
>                 Key: GROOVY-8251
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8251
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-jdk
>    Affects Versions: 2.5.0-beta-1
>            Reporter: Henri Tremblay
>
> The Groovy implementation of try-with-resource is through 
> {{withCloseable()}}. The problem is that {{withCloseable}} only exists for 
> classes implementing the {{Closeable}} interface.
> But a try-with-resource works with the {{AutoCloseable}} interface. So 
> {{withCloseable}} should probably be moved on step below to {{AutoCloseable}} 
> (that {{Closeable}} extends).



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to