On Jun 16, 2015, at 4:41 AM, Romain Manni-Bucau <rmannibu...@gmail.com> wrote:

> Le 16 juin 2015 02:04, "David Blevins" <david.blev...@gmail.com> a écrit :
>> 
>> On Jun 15, 2015, at 7:26 PM, Romain Manni-Bucau <rmannibu...@gmail.com>
> wrote:
>> 
>>>> 
>>>> 
>>>>> The trick is we need to rely on shutdown() being called when the bean
> is
>>>>> undeployed to ensure the application can successfully terminate and
> not
>>>>> leak timers.
>>>>> 
>>>> 
>>> 
>>> we can use ScheduledTask#cancel then
>>> 
>>> will change it and add a flag to go back to previous behavior if desired
>> 
>> No need for a flag if it works.
>> 
>> The cancel as opposed to shutdown has no wait time yet can return false
> signifying the timer will continue to fire.
>> 
>> We'd have to test it to ensure it works, but in the event cancel returns
> false we might want to call get(long, TimeUnit) on the future to see if we
> can wait for completion and try the cancel again.
>> 
> 
> No, would block shutdown. We already wait for completion not interrupting
> the task.

Can you expand on that?  The goal is definitely to block undeploy till undeploy 
is actually complete.

I checked out the code for ScheduledExecutorService yesterday and it appeared 
the cancel call will not remove the timer if the timer is being currently fired 
nor will it wait for the timer to complete and remove it afterwards.  This 
means that the sweeper will stay running and the app will leak.


-David

Reply via email to