Philippe,
On 04/01/2013 21:12, Philippe Marschall wrote:
>
> The way my code usually looks is like this:
>
> TemporaryQueue queue = session.createTemporaryQueue(…);
> try {
> // work with queue
> } finally {
> queue.delete();
> }
>
> with AutoCloseable it would look like this
>
> try (TemporaryQueue queue = session.createTemporaryQueue(…)) {
> // work with queue
> }
>
> Again, I'm not sure whether this is a good idea™ or a misuse of a
> language feature.
Thanks. So your proposal is that we make TemporaryQueue and
TemporaryTopic implement AutoCloseable. This would add new close()
methods which would do the same as the existing delete() methods.
I can see the advantage of this, but I think this is a bit of a misuse
as you suggest. The existing method is delete, not close, no doubt
because the original authors deliberately decided that this was
semantically a "delete" rather than a "close". We should probably not
try to override that just to allow us to use AutoCloseable. And having
two method that do the same thing is not a good design.
Nigel