[Asterisk-java-users] ManagerReader Interrupt
Brought to you by:
srt
From: Brett S. <bs...@no...> - 2006-03-04 11:19:46
|
I believe that there is a bug in the DefaultManagerConnection.sendAction(ManagerAction action, long timeout) method. The problem is with the creation of the ResponseHandlerResult. The ResponseHandlerResult calls thread.interrupt to wake up the thread which called sendAction. Thats fine, the problem begins when the sendAction returns (with or without a response). Calling Thread.interupt leaves the thread in an interrupted state until some method (such as sleep) checks the threads interrupt state at which point the interrupt state is cleared. The problem occurs if the call to interrupt is made when sendAction is not currently sleeping. There are numerous ways in which this can happen. The impact on sendAction is zero. However if an application then calls a method such as Thread.sleep or Queue.take the method call will immediately throw an Interrupted exception as the thread is still in an interrupted state. I believe a better way of dealing with this problem is to use Object.wait(x) and Object.notify. For the purposes of sendAction the affects are identical without the nasty side effects of calling interrupt. I hope this makes some sense. Regards, Brett. |