activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r514717 - in /activemq/trunk/activemq-core/src/main/java/org/apache/activemq: ActiveMQConnection.java ActiveMQConnectionFactory.java
Date Mon, 05 Mar 2007 16:00:26 GMT
Author: jlim
Date: Mon Mar  5 08:00:25 2007
New Revision: 514717

URL: http://svn.apache.org/viewvc?view=rev&rev=514717
Log:
ported fix to trunk : 
http://issues.apache.org/activemq/browse/AMQ-1177

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java?view=diff&rev=514717&r1=514716&r2=514717
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java
Mon Mar  5 08:00:25 2007
@@ -577,10 +577,12 @@
                     }
 
                     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);

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java?view=diff&rev=514717&r1=514716&r2=514717
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java
Mon Mar  5 08:00:25 2007
@@ -239,11 +239,11 @@
         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);
             connection.setPrefetchPolicy(getPrefetchPolicy());
@@ -269,10 +269,14 @@
             return connection;
         }
         catch (JMSException e) {
+        	// Clean up!
+        	try { connection.close(); } catch ( Throwable ignore ) {}
             throw e;
         }
         catch (Exception e) {
-            throw JMSExceptionSupport.create("Could not connect to broker URL: " + brokerURL
+ ". Reason: " + e, e);
+        	// Clean up!
+        	try { connection.close(); } catch ( Throwable ignore ) {}
+        	throw JMSExceptionSupport.create("Could not connect to broker URL: " + brokerURL
+ ". Reason: " + e, e);
         }
     }
 



Mime
View raw message