You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@activemq.apache.org by "Gary Tully (JIRA)" <ji...@apache.org> on 2015/11/27 14:01:10 UTC

[jira] [Commented] (AMQ-3547) Calling Connection.close() on interrupted thread generates InterruptedIOException and leaks Connection

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

Gary Tully commented on AMQ-3547:
---------------------------------

As part of the reqworked fix for https://issues.apache.org/jira/browse/AMQ-2191 - the need to wrap close operaitons with suspended interrupts goes away. There is a more general form of your test that verifies all is still good.
Essentially, the suspend/resume interrupt is moved into FutureResponse where the InterruptedException is handled as a failure 'only' during a request. Requests and oneways can be safely invoked while interrupted and the interrupted state is retained.

It would be great if you could cast your eyes over the reworked fix in AMQ-2191 

> Calling Connection.close() on interrupted thread generates InterruptedIOException and leaks Connection
> ------------------------------------------------------------------------------------------------------
>
>                 Key: AMQ-3547
>                 URL: https://issues.apache.org/jira/browse/AMQ-3547
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: JMS client
>    Affects Versions: 5.5.0
>            Reporter: Martin Beránek
>            Assignee: Timothy Bish
>            Priority: Critical
>             Fix For: 5.6.0
>
>         Attachments: AMQ3529Test.java, AMQ3529Test.java
>
>
> Similar to https://issues.apache.org/jira/browse/AMQ-3529
> call close() method on connection raise JMSException with InterruptedIOException as cause
> Sample program:
> public static void main(String[] args) throws Exception {
> 	ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616");
> 	Connection connection = connectionFactory.createConnection();
> 	Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
> 	final Thread mainThread = Thread.currentThread();
> 	new Thread() {
> 		public void run() {
> 			// this thread interrupt main thread after 1s
> 			try {
> 				Thread.sleep(1000);
> 			} catch (InterruptedException e) {
> 			}
> 			mainThread.interrupt();
> 		};
> 	}.start();
> 	try {
> 		//wait for interrupt
> 		Thread.sleep(10000);
> 	} catch (InterruptedException e) {
> 		Thread.currentThread().interrupt();
> 	}
> 	try {
> 		// this generate exception - bug???
> 		connection.close();
> 	} catch (JMSException e) {
> 		e.printStackTrace();
> 	}
> 	// non-daemon thread responsible for connection still running, program
> 	// will not terminate
> }
> when I remove line with Session obtain, everything works OK



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