Some Classes with a public void close() don't implement AutoCloseable
Andrew Haley
aph at redhat.com
Wed Apr 22 12:50:04 UTC 2020
On 4/21/20 10:06 PM, Stuart Marks wrote:
> (The usual objection to this construct is if closing the wrapper closes the
> underlying reader, the t-w-r will close it again. This isn't a problem for
> BufferedReader and most JDK I/O classes, as close() is idempotent for them.)
So here's a Java design question (or two) for you:
1. Should close() always be idempotent, where practical? I would have
thought so, but perhaps there are downsides.
2. Should classes which implement close() with the standard meaning be
AutoCloseable?
--
Andrew Haley (he/him)
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
https://keybase.io/andrewhaley
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671
More information about the core-libs-dev
mailing list