mirror of https://github.com/apache/activemq.git
r237@34: chirino | 2007-02-23 14:48:28 -0500
Fixing memory leak that could occur if a connection attemp is not successful (for example if the broker is down and failover is not being used). If the client app loops re-attempting to reconnect and continues to fail, the leak to lead to a OOM exception quickly. git-svn-id: https://svn.apache.org/repos/asf/activemq/branches/activemq-4.1@511081 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
579bc65ae3
commit
88d56499d9
|
@ -573,10 +573,12 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon
|
|||
}
|
||||
|
||||
if (isConnectionInfoSentToBroker) {
|
||||
// If we announced ourselfs to the broker.. Try to let the broker
|
||||
// know that the connection is being shutdown.
|
||||
syncSendPacket(info.createRemoveCommand(), closeTimeout);
|
||||
asyncSendPacket(new ShutdownInfo());
|
||||
}
|
||||
|
||||
asyncSendPacket(new ShutdownInfo());
|
||||
ServiceSupport.dispose(this.transport);
|
||||
|
||||
started.set(false);
|
||||
|
|
|
@ -239,10 +239,10 @@ public class ActiveMQConnectionFactory extends JNDIBaseStorable implements Conne
|
|||
if (brokerURL == null) {
|
||||
throw new ConfigurationException("brokerURL not set.");
|
||||
}
|
||||
Transport transport;
|
||||
ActiveMQConnection connection=null;
|
||||
try {
|
||||
transport = createTransport();
|
||||
ActiveMQConnection connection = createActiveMQConnection(transport, factoryStats);
|
||||
Transport transport = createTransport();
|
||||
connection = createActiveMQConnection(transport, factoryStats);
|
||||
|
||||
connection.setUserName(userName);
|
||||
connection.setPassword(password);
|
||||
|
@ -268,9 +268,13 @@ public class ActiveMQConnectionFactory extends JNDIBaseStorable implements Conne
|
|||
return connection;
|
||||
}
|
||||
catch (JMSException e) {
|
||||
// Clean up!
|
||||
try { connection.close(); } catch ( Throwable ignore ) {}
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e) {
|
||||
// Clean up!
|
||||
try { connection.close(); } catch ( Throwable ignore ) {}
|
||||
throw JMSExceptionSupport.create("Could not connect to broker URL: " + brokerURL + ". Reason: " + e, e);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue