[ 
https://issues.apache.org/jira/browse/QPID-6518?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14521320#comment-14521320
 ] 

Rob Godfrey commented on QPID-6518:
-----------------------------------

Looking at your code, I'm not sure it is really necessary to call interrupt() 
in destroy() as simply calling connection.close() should ensure that the loop 
terminates (since calling close will cause blocking receives to immediately 
return).  

As you observe, calling close() causes interrupts to occur (to stop the client 
code waiting forever for a new message to arrive), it's not clear to me that 
there is an easy way to ensure that a spurious interrupt caused by this logic 
*never* leaks out to the calling code, however we can greatly reduce the 
possibility.  Rather than looping on 

{code}
while (! (Thread.currentThread().isInterrupted()))
{code}

perhaps you could add a 
{code}
private volatile boolean destroyed; 
{code}

field to your bean, loop on 
{code}
while(!destroyed)
{code}

and set destroyed to true in your destroy() method?

> Cyclic errors on thread interruption thru resetting interrupted flag
> --------------------------------------------------------------------
>
>                 Key: QPID-6518
>                 URL: https://issues.apache.org/jira/browse/QPID-6518
>             Project: Qpid
>          Issue Type: Bug
>          Components: Java Client
>    Affects Versions: 0.32
>         Environment: WildFly 8.2.0.Final, RabbitMQ 3.5.1
>            Reporter: Nikita Konev
>            Assignee: Rob Godfrey
>         Attachments: OurBean.java, wildfly-log.txt
>
>   Original Estimate: 2h
>  Remaining Estimate: 2h
>
> When i attempt undeploy application caused backgroundProcess.interrupt() in 
> OurBean.java:72, sometimes may occur InterruptedException in 
> BasicMessageConsumer.receive(). It resets interrupted flag of thread that 
> resulting cyclic errors because thread is not interrupted.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@qpid.apache.org
For additional commands, e-mail: dev-h...@qpid.apache.org

Reply via email to