fix memory leak in ActiveMQConnection - with asyncConnectionThread not being shutdown on a close

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@581683 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Davies 2007-10-03 18:50:03 +00:00
parent 5bd3bf6e24
commit 08841bbde3
1 changed files with 20 additions and 13 deletions

View File

@ -594,6 +594,10 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon
// factory.onConnectionClose(this); // factory.onConnectionClose(this);
sessionTaskRunner.shutdown(); sessionTaskRunner.shutdown();
if (asyncConnectionThread != null){
asyncConnectionThread.shutdown();
}
closed.set(true); closed.set(true);
closing.set(false); closing.set(false);
} }
@ -1653,19 +1657,22 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon
public void onException(final IOException error) { public void onException(final IOException error) {
onAsyncException(error); onAsyncException(error);
if (!closing.get() && !closed.get()) {
asyncConnectionThread.execute(new Runnable() { asyncConnectionThread.execute(new Runnable() {
public void run() { public void run() {
transportFailed(error); transportFailed(error);
ServiceSupport.dispose(ActiveMQConnection.this.transport); ServiceSupport.dispose(ActiveMQConnection.this.transport);
brokerInfoReceived.countDown(); brokerInfoReceived.countDown();
for (Iterator<TransportListener> iter = transportListeners.iterator(); iter.hasNext();) { for (Iterator<TransportListener> iter = transportListeners
.iterator(); iter.hasNext();) {
TransportListener listener = iter.next(); TransportListener listener = iter.next();
listener.onException(error); listener.onException(error);
} }
} }
}); });
} }
}
public void transportInterupted() { public void transportInterupted() {
for (Iterator<ActiveMQSession> i = this.sessions.iterator(); i.hasNext();) { for (Iterator<ActiveMQSession> i = this.sessions.iterator(); i.hasNext();) {