RFR: 8066869: Add Closeable::closeUnchecked that is the equivalent of close but throws UncheckedIOException [v2]

Joe Darcy darcy at openjdk.org
Mon Jul 10 17:27:12 UTC 2023


On Fri, 7 Jul 2023 15:56:13 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> Add a default method `java.io.Closeable::closeUnchecked` which is equivalent to `Closeable::close` except that it instead throws `java.io.UncheckedIOException`.
>
> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8066869: linkplain -> link

Hmm.

If the goal was to preserve the ability to use the try-with-resources statement, then a utility method that wrapped a java.io.Closeable with a java.io.UncheckedCloseable would be needed, where UncheckedCloseable had a close method that was declared to not throw any exceptions and did the IOException wrapping.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/14789#issuecomment-1629398735


More information about the core-libs-dev mailing list