openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1369233 - /openwebbeans/trunk/webbeans-jms/src/main/java/org/apache/webbeans/jms/util/JmsProxyHandler.java
Date Fri, 03 Aug 2012 22:14:02 GMT
Author: struberg
Date: Fri Aug  3 22:14:02 2012
New Revision: 1369233

URL: http://svn.apache.org/viewvc?rev=1369233&view=rev
Log:
OWB-691 cleanly close the connection

Modified:
    openwebbeans/trunk/webbeans-jms/src/main/java/org/apache/webbeans/jms/util/JmsProxyHandler.java

Modified: openwebbeans/trunk/webbeans-jms/src/main/java/org/apache/webbeans/jms/util/JmsProxyHandler.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-jms/src/main/java/org/apache/webbeans/jms/util/JmsProxyHandler.java?rev=1369233&r1=1369232&r2=1369233&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-jms/src/main/java/org/apache/webbeans/jms/util/JmsProxyHandler.java
(original)
+++ openwebbeans/trunk/webbeans-jms/src/main/java/org/apache/webbeans/jms/util/JmsProxyHandler.java
Fri Aug  3 22:14:02 2012
@@ -165,32 +165,39 @@ public class JmsProxyHandler implements 
         }
         catch (JMSException e)
         {
-            if (connection != null)
-            {
-                try
-                {
-                    connection.close();
-                }
-                catch (JMSException jmse)
-                {
-                    // do nothing, we are already throwing up anyway...
-                }
-            }
+            ensureConnectionClosing(connection);
             throw new WebBeansException("Unable to create jms session", e);
         }
 
     }
 
+    private void ensureConnectionClosing(Connection connection)
+    {
+        if (connection != null)
+        {
+            try
+            {
+                connection.close();
+            }
+            catch (JMSException jmse)
+            {
+                // do nothing, we are already throwing up anyway...
+            }
+        }
+    }
+
     private MessageProducer createMessageProducers()
     {
+        Connection connection = null;
         try
         {
-            Connection connection = createOrReturnQueueOrTopicConnection();
+            connection = createOrReturnQueueOrTopicConnection();
 
             return connection.createSession(false, Session.AUTO_ACKNOWLEDGE).createProducer(createOrReturnQueueOrTopic());
         }
         catch (JMSException e)
         {
+            ensureConnectionClosing(connection);
             throw new WebBeansException("Unable to create jms message producer", e);
         }
 
@@ -198,14 +205,16 @@ public class JmsProxyHandler implements 
 
     private MessageConsumer createMessageConsumers()
     {
+        Connection connection = null;
         try
         {
-            Connection connection = createOrReturnQueueOrTopicConnection();
+            connection = createOrReturnQueueOrTopicConnection();
 
             return connection.createSession(false, Session.AUTO_ACKNOWLEDGE).createConsumer(createOrReturnQueueOrTopic());
         }
         catch (JMSException e)
         {
+            ensureConnectionClosing(connection);
             throw new WebBeansException("Unable to create jms message producer", e);
         }
 



Mime
View raw message