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

@ -593,6 +593,10 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon
// then we may need to call // then we may need to call
// 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);
@ -1652,20 +1656,23 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon
} }
public void onException(final IOException error) { public void onException(final IOException error) {
onAsyncException(error); onAsyncException(error);
asyncConnectionThread.execute(new Runnable() { if (!closing.get() && !closed.get()) {
public void run() { asyncConnectionThread.execute(new Runnable() {
transportFailed(error); public void run() {
ServiceSupport.dispose(ActiveMQConnection.this.transport); transportFailed(error);
brokerInfoReceived.countDown(); ServiceSupport.dispose(ActiveMQConnection.this.transport);
brokerInfoReceived.countDown();
for (Iterator<TransportListener> iter = transportListeners.iterator(); iter.hasNext();) { for (Iterator<TransportListener> iter = transportListeners
TransportListener listener = iter.next(); .iterator(); iter.hasNext();) {
listener.onException(error); TransportListener listener = iter.next();
} 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();) {