groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John Wagenleitner (JIRA)" <>
Subject [jira] [Commented] (GROOVY-8251) Implement withCloseable on AutoCloseable
Date Thu, 06 Jul 2017 18:20:00 GMT


John Wagenleitner commented on GROOVY-8251:

My initial thought was sort of the same, just add a {{withCloseable(AutoCloseable..) throws
Exception}} method.  I don't think there is any limitation, other than the old {{withCloseable(Closeable..)
throws IOException}} method would probably need to be kept for binary compatibility.  The
{{throws}} clause of the old method would probably need to change but don't think that is
a problem.

There may be some confusion with the name {{withCloseable}} taking either a {{Closeable}}
or {{AutoCloseable}}, given that {{AutoCloseable}} is the more general type.  But I like the
concise name {{withCloseable}} more.

> Implement withCloseable on AutoCloseable
> ----------------------------------------
>                 Key: GROOVY-8251
>                 URL:
>             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

View raw message