users@jms-spec.java.net

[jms-spec users] [jsr343-experts] Re: Re: Re: Make TemporaryQueue/Topic AutoCloseable?

From: Clebert Suconic <clebert.suconic_at_gmail.com>
Date: Mon, 7 Jan 2013 10:48:12 -0600

Besides that would introduce semantic changes. What if the Topic is beyond
context but not the Consumer or Producer.

I as well, don't think that would be a good idea to make this change.


On Mon, Jan 7, 2013 at 6:57 AM, Nigel Deakin <nigel.deakin_at_oracle.com>wrote:

> 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
>
>
>


-- 
Clebert Suconic
http://community.jboss.org/people/clebert.suconic@jboss.com
http://clebertsuconic.blogspot.com