You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rg...@apache.org on 2015/02/10 14:37:01 UTC

svn commit: r1658714 - in /qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client: AMQConnection.java AMQSession_0_8.java

Author: rgodfrey
Date: Tue Feb 10 13:37:00 2015
New Revision: 1658714

URL: http://svn.apache.org/r1658714
Log:
QPID-6374 : tidyup calls to connection task pool

Modified:
    qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java
    qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_8.java

Modified: qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java?rev=1658714&r1=1658713&r2=1658714&view=diff
==============================================================================
--- qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java (original)
+++ qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java Tue Feb 10 13:37:00 2015
@@ -32,6 +32,7 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
+import java.util.concurrent.RejectedExecutionException;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
 
@@ -1353,16 +1354,23 @@ public class AMQConnection extends Close
         if (exceptionListener != null)
         {
             performConnectionTask(new Runnable()
-                                    {
-                                        @Override
-                                        public void run()
-                                        {
-                                            // deliver the exception if there is a listener
-                                                exceptionListener.onException(je);
-                                        }
-                                    });
-        }
-        else
+                                  {
+                                      @Override
+                                      public void run()
+                                      {
+                                          // deliver the exception if there is a listener
+                                          try
+                                          {
+                                              exceptionListener.onException(je);
+                                          }
+                                          catch (RuntimeException e)
+                                          {
+                                              _logger.error("Exception occurred in ExceptionListener", e);
+                                          }
+                                      }
+                                  });
+            }
+            else
         {
             _logger.error("Throwable Received but no listener set: " + cause);
         }
@@ -1478,7 +1486,17 @@ public class AMQConnection extends Close
 
     public void performConnectionTask(Runnable task)
     {
-        _taskPool.execute(task);
+        try
+        {
+            _taskPool.execute(task);
+        }
+        catch (RejectedExecutionException e)
+        {
+            if(!(isClosed() || isClosing()))
+            {
+                throw e;
+            }
+        }
     }
 
     public AMQSession getSession(int channelId)

Modified: qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_8.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_8.java?rev=1658714&r1=1658713&r2=1658714&view=diff
==============================================================================
--- qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_8.java (original)
+++ qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_8.java Tue Feb 10 13:37:00 2015
@@ -772,42 +772,47 @@ public class AMQSession_0_8 extends AMQS
 
     private void returnBouncedMessage(final ReturnMessage msg)
     {
-        getAMQConnection().performConnectionTask(new Runnable()
+        try
         {
-            public void run()
-            {
-                try
-                {
-                    // Bounced message is processed here, away from the mina thread
-                    AbstractJMSMessage bouncedMessage =
-                            getMessageFactoryRegistry().createMessage(0, false, msg.getExchange(),
-                                    msg.getRoutingKey(), msg.getContentHeader(), msg.getBodies(), _queueDestinationCache,
-                                    _topicDestinationCache, AMQDestination.UNKNOWN_TYPE);
-                    AMQConstant errorCode = AMQConstant.getConstant(msg.getReplyCode());
-                    AMQShortString reason = msg.getReplyText();
-                    _logger.debug("Message returned with error code " + errorCode + " (" + reason + ")");
-
-                    // @TODO should this be moved to an exception handler of sorts. Somewhere errors are converted to correct execeptions.
-                    if (errorCode == AMQConstant.NO_CONSUMERS)
-                    {
-                        getAMQConnection().exceptionReceived(new AMQNoConsumersException("Error: " + reason, bouncedMessage, null));
-                    } else if (errorCode == AMQConstant.NO_ROUTE)
-                    {
-                        getAMQConnection().exceptionReceived(new AMQNoRouteException("Error: " + reason, bouncedMessage, null));
-                    } else
-                    {
-                        getAMQConnection().exceptionReceived(
-                                new AMQUndeliveredException(errorCode, "Error: " + reason, bouncedMessage, null));
-                    }
+            // Bounced message is processed here, away from the mina thread
+            AbstractJMSMessage bouncedMessage =
+                    getMessageFactoryRegistry().createMessage(0,
+                                                              false,
+                                                              msg.getExchange(),
+                                                              msg.getRoutingKey(),
+                                                              msg.getContentHeader(),
+                                                              msg.getBodies(),
+                                                              _queueDestinationCache,
+                                                              _topicDestinationCache,
+                                                              AMQDestination.UNKNOWN_TYPE);
+            AMQConstant errorCode = AMQConstant.getConstant(msg.getReplyCode());
+            AMQShortString reason = msg.getReplyText();
+            _logger.debug("Message returned with error code " + errorCode + " (" + reason + ")");
 
-                } catch (Exception e)
-                {
-                    _logger.error(
-                            "Caught exception trying to raise undelivered message exception (dump follows) - ignoring...",
-                            e);
-                }
+            // @TODO should this be moved to an exception handler of sorts. Somewhere errors are converted to correct execeptions.
+            if (errorCode == AMQConstant.NO_CONSUMERS)
+            {
+                getAMQConnection().exceptionReceived(new AMQNoConsumersException("Error: " + reason,
+                                                                                 bouncedMessage,
+                                                                                 null));
+            }
+            else if (errorCode == AMQConstant.NO_ROUTE)
+            {
+                getAMQConnection().exceptionReceived(new AMQNoRouteException("Error: " + reason, bouncedMessage, null));
             }
-        });
+            else
+            {
+                getAMQConnection().exceptionReceived(
+                        new AMQUndeliveredException(errorCode, "Error: " + reason, bouncedMessage, null));
+            }
+
+        }
+        catch (Exception e)
+        {
+            _logger.error(
+                    "Caught exception trying to raise undelivered message exception (dump follows) - ignoring...",
+                    e);
+        }
     }
 
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org