MumbleCloseable

Doug Lea dl at cs.oswego.edu
Tue Jun 25 07:55:33 PDT 2013


On 06/24/13 21:04, Brian Goetz wrote:

> The key goals here are that we want to support both:
>   - Users who care about guaranteed resource release being able to reliably do
> so unintrusively, without
>   - Users who don't care having to pay attention if they don't want to.

As someone who has hit these issues several times before without
providing a really great solution, I think the plan here is better
than others we've considered (like resisting people's requests that
we provide some way to close/shut-down BlockingQueues, and
not making ExecutorService AutoCloseable because there are
multiple means of shutdown. Plus other cases Brian mentioned.)

I like the idea of an construction saying that "implementations
of this type may hold resources, and if so you should use them
with try-with-resources". Too bad that none of the obvious/simple
ways to do this work. But of the less obvious approaches,
creating a type "PossiblyHoldsResourcesUntilClosed" seems to be
one part of solution. I think that to be useful, there should
also be an annotation @HoldsResourcesUntilClosed that can
be placed on those implementation classes etc that do
in general want to be used with TWR, so IDEs and tools can help
people do the right thing.

These together provide something better than any other related
schemes I know. I think that if we cam up with stunningly
good names for these, the plan would be completely uncontroversial.

-Doug



More information about the lambda-libs-spec-experts mailing list