Author: orudyy
Date: Thu Aug 28 15:00:06 2014
New Revision: 1621146

URL: http://svn.apache.org/r1621146
Log:
QPID-6051: Allow exceptions from post commit actions to be handled in the 
callers

Modified:
    
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/txn/LocalTransaction.java
    
qpid/trunk/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngine.java

Modified: 
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/txn/LocalTransaction.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/txn/LocalTransaction.java?rev=1621146&r1=1621145&r2=1621146&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/txn/LocalTransaction.java
 (original)
+++ 
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/txn/LocalTransaction.java
 Thu Aug 28 15:00:06 2014
@@ -24,8 +24,6 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
-import org.apache.qpid.server.util.ConnectionScopedRuntimeException;
-import org.apache.qpid.transport.TransportException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -259,11 +257,6 @@ public class LocalTransaction implements
 
             doPostTransactionActions();
         }
-        catch(RuntimeException e)
-        {
-            doRollbackActions();
-            throw e;
-        }
         finally
         {
             resetDetails();
@@ -282,11 +275,9 @@ public class LocalTransaction implements
     {
         sync();
         StoreFuture future = StoreFuture.IMMEDIATE_FUTURE;
-        try
+        if(_transaction != null)
         {
-            if(_transaction != null)
-            {
-                future = new StoreFuture()
+            future = new StoreFuture()
                         {
                             private volatile boolean _completed = false;
                             private StoreFuture _underlying = 
_transaction.commitTranAsync();
@@ -325,21 +316,16 @@ public class LocalTransaction implements
                                     doPostTransactionActions();
                                     deferred.run();
                                 }
-                                catch (RuntimeException e)
-                                {
-                                    handleUnexpectedException(e);
-                                }
                                 finally
                                 {
                                     resetDetails();
                                 }
                             }
-
-                };
-                _asyncTran = future;
-            }
-            else
-            {
+            };
+            _asyncTran = future;
+        }
+        else
+        {
                 try
                 {
                     doPostTransactionActions();
@@ -349,44 +335,10 @@ public class LocalTransaction implements
                 {
                     resetDetails();
                 }
-            }
-
-        }
-        catch (RuntimeException e)
-        {
-            try
-            {
-                handleUnexpectedException(e);
-            }
-            finally
-            {
-                resetDetails();
-            }
         }
         return future;
     }
 
-    private void handleUnexpectedException(RuntimeException e)
-    {
-        if(e instanceof ConnectionScopedRuntimeException || e instanceof 
TransportException)
-        {
-            throw e;
-        }
-        else
-        {
-            _logger.error("Unexpected exception on execution of post commit 
deferred actions", e);
-            boolean continueOnError = 
Boolean.getBoolean("qpid.broker.exceptionHandler.continue");
-            if (continueOnError)
-            {
-                throw e;
-            }
-            else
-            {
-                Runtime.getRuntime().halt(1);
-            }
-        }
-    }
-
     private void doPostTransactionActions()
     {
         if(_logger.isDebugEnabled())

Modified: 
qpid/trunk/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngine.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngine.java?rev=1621146&r1=1621145&r2=1621146&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngine.java
 (original)
+++ 
qpid/trunk/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngine.java
 Thu Aug 28 15:00:06 2014
@@ -318,7 +318,7 @@ public class AMQProtocolEngine implement
                             }
                             break;
                         }
-                        catch (Exception e)
+                        catch (AMQException e)
                         {
                             _logger.error("Unexpected exception when 
processing datablock", e);
                             closeProtocolSession();
@@ -337,6 +337,11 @@ public class AMQProtocolEngine implement
                     _logger.error("Unexpected protocol version", e);
                     closeProtocolSession();
                 }
+                catch (TransportException e)
+                {
+                    _logger.error("Unexpected transport exception", e);
+                    closeProtocolSession();
+                }
                 catch (AMQFrameDecodingException e)
                 {
                     _logger.error("Frame decoding", e);
@@ -394,7 +399,7 @@ public class AMQProtocolEngine implement
      * the connection is already closed by the time the exception is thrown. 
If any other
      * type of exception is thrown, the connection is not already closed.
      */
-    private void dataBlockReceived(AMQDataBlock message) throws Exception
+    private void dataBlockReceived(AMQDataBlock message) throws AMQException
     {
         if (message instanceof ProtocolInitiation)
         {



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to