Hello, Brian! Thanks for your thoughts. > The consumeAndClose approach is clever, in that it adds one API point that > works for all streams, rather than having to add a new API point for every > factory of a closeable stream; on the other hand, it is dramatically less > discoverable, and so requires more education to get people to use it (and, as > you say, has the exception problem.)
I think this could be solved via IDE/static analysis features. It looks quite easy to statically rewrite the try-catch statement to consumeAndClose. And, of course, static analyzers may recommend consumeAndClose when no resource management is used at all on the stream that is known to hold the resource. I filed https://bugs.openjdk.java.net/browse/JDK-8274412 to move this forward.