activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1451649 - /activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/SessionPool.java
Date Fri, 01 Mar 2013 16:56:26 GMT
Author: tabish
Date: Fri Mar  1 16:56:26 2013
New Revision: 1451649

URL: http://svn.apache.org/r1451649
Log:
fix for: https://issues.apache.org/jira/browse/AMQ-4359

Modified:
    activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/SessionPool.java

Modified: activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/SessionPool.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/SessionPool.java?rev=1451649&r1=1451648&r2=1451649&view=diff
==============================================================================
--- activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/SessionPool.java (original)
+++ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/SessionPool.java Fri
Mar  1 16:56:26 2013
@@ -36,7 +36,7 @@ public class SessionPool {
 
     private ConnectionFactory connectionFactory;
     private Connection connection;
-    private LinkedList<Session> sessions = new LinkedList<Session>();
+    private final LinkedList<Session> sessions = new LinkedList<Session>();
 
     public Connection getConnection() throws JMSException {
         if (checkConnection()) {
@@ -44,9 +44,16 @@ public class SessionPool {
         }
 
         synchronized (this) {
-            connection = getConnectionFactory().createConnection();
-            connection.start();
-            return connection;
+            try {
+                connection = getConnectionFactory().createConnection();
+                connection.start();
+                return connection;
+            } catch (JMSException jmsEx) {
+                LOG.debug("Caught exception while attempting to get a new Connection.", jmsEx);
+                connection.close();
+                connection = null;
+                throw jmsEx;
+            }
         }
     }
 
@@ -106,5 +113,4 @@ public class SessionPool {
     protected Session createSession() throws JMSException {
         return getConnection().createSession(false, Session.AUTO_ACKNOWLEDGE);
     }
-
 }



Mime
View raw message