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 2014/02/14 20:23:18 UTC

svn commit: r1568495 [6/8] - in /qpid/branches/java-broker-amqp-1-0-management/java: ./ amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ bdbstore/jmx/src/main/java/org/apache/qpid/server/store/berkeleydb/jmx/ bdbstore/jmx/src/test/java...

Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueTestBase.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueTestBase.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueTestBase.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueTestBase.java Fri Feb 14 19:23:14 2014
@@ -34,9 +34,8 @@ import java.util.EnumSet;
 import java.util.Map;
 
 import org.apache.log4j.Logger;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.AMQInternalException;
-import org.apache.qpid.AMQSecurityException;
+import org.apache.qpid.server.message.MessageSource;
+import org.apache.qpid.server.security.QpidSecurityException;
 import org.apache.qpid.exchange.ExchangeDefaults;
 import org.apache.qpid.server.exchange.DirectExchange;
 import org.apache.qpid.server.message.AMQMessageHeader;
@@ -100,7 +99,7 @@ abstract class SimpleAMQQueueTestBase<E 
         }
     }
 
-    public void testCreateQueue() throws AMQException
+    public void testCreateQueue() throws Exception
     {
         _queue.stop();
         try
@@ -129,7 +128,7 @@ abstract class SimpleAMQQueueTestBase<E 
         assertEquals("Virtual host was wrong", _virtualHost, _queue.getVirtualHost());
     }
 
-    public void testBinding() throws AMQSecurityException, AMQInternalException
+    public void testBinding() throws QpidSecurityException
     {
         _exchange.addBinding(_routingKey, _queue, Collections.EMPTY_MAP);
 
@@ -150,7 +149,7 @@ abstract class SimpleAMQQueueTestBase<E 
 
     }
 
-    public void testRegisterConsumerThenEnqueueMessage() throws AMQException
+    public void testRegisterConsumerThenEnqueueMessage() throws Exception
     {
         ServerMessage messageA = createMessage(new Long(24));
 
@@ -188,7 +187,7 @@ abstract class SimpleAMQQueueTestBase<E 
 
     }
 
-    public void testEnqueueMessageThenRegisterConsumer() throws AMQException, InterruptedException
+    public void testEnqueueMessageThenRegisterConsumer() throws Exception, InterruptedException
     {
         ServerMessage messageA = createMessage(new Long(24));
         _queue.enqueue(messageA, null);
@@ -420,7 +419,7 @@ abstract class SimpleAMQQueueTestBase<E 
                    consumer2.getQueueContext().getReleasedEntry());
     }
 
-    public void testExclusiveConsumer() throws AMQException
+    public void testExclusiveConsumer() throws Exception
     {
         ServerMessage messageA = createMessage(new Long(24));
         // Check adding an exclusive consumer adds it to the queue
@@ -456,7 +455,7 @@ abstract class SimpleAMQQueueTestBase<E 
                                           Consumer.Option.SEES_REQUEUES));
 
         }
-        catch (AMQException e)
+        catch (MessageSource.ExistingExclusiveConsumer e)
         {
            ex = e;
         }
@@ -476,7 +475,7 @@ abstract class SimpleAMQQueueTestBase<E 
                                                EnumSet.of(Consumer.Option.EXCLUSIVE));
 
         }
-        catch (AMQException e)
+        catch (MessageSource.ExistingConsumerPreventsExclusive e)
         {
            ex = e;
         }
@@ -499,14 +498,8 @@ abstract class SimpleAMQQueueTestBase<E 
             {
                 QueueEntryImpl entry = (QueueEntryImpl) object;
                 entry.setRedelivered();
-                try
-                {
-                    _consumer.resend(entry);
-                }
-                catch (AMQException e)
-                {
-                    fail("Exception thrown: " + e.getMessage());
-                }
+                _consumer.resend(entry);
+
             }
         });
 
@@ -837,7 +830,7 @@ abstract class SimpleAMQQueueTestBase<E 
      * Tests that all messages including dequeued one are deleted from the queue
      * on invocation of {@link SimpleAMQQueue#clearQueue()}
      */
-    public void testClearQueueWithDequeuedEntry()
+    public void testClearQueueWithDequeuedEntry() throws Exception
     {
         int messageNumber = 4;
         int dequeueMessageIndex = 1;
@@ -849,14 +842,7 @@ abstract class SimpleAMQQueueTestBase<E 
         dequeueMessage(_queue, dequeueMessageIndex);
 
         // clean queue
-        try
-        {
-            _queue.clearQueue();
-        }
-        catch (AMQException e)
-        {
-            fail("Failure to clear queue:" + e.getMessage());
-        }
+        _queue.clearQueue();
 
         // get queue entries
         List<E> entries = _queue.getMessagesOnTheQueue();
@@ -942,23 +928,11 @@ abstract class SimpleAMQQueueTestBase<E 
         {
             // Create message
             ServerMessage message = null;
-            try
-            {
-                message = createMessage((long)i);
-            }
-            catch (AMQException e)
-            {
-                fail("Failure to create a test message:" + e.getMessage());
-            }
+            message = createMessage((long)i);
+
             // Put message on queue
-            try
-            {
-                queue.enqueue(message,null);
-            }
-            catch (AMQException e)
-            {
-                fail("Failure to put message on queue:" + e.getMessage());
-            }
+            queue.enqueue(message,null);
+
         }
         try
         {
@@ -1037,7 +1011,7 @@ abstract class SimpleAMQQueueTestBase<E 
     }
 
 
-    protected ServerMessage createMessage(Long id) throws AMQException
+    protected ServerMessage createMessage(Long id)
     {
         AMQMessageHeader header = mock(AMQMessageHeader.class);
         when(header.getMessageId()).thenReturn(String.valueOf(id));

Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleQueueEntryImplTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleQueueEntryImplTest.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleQueueEntryImplTest.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleQueueEntryImplTest.java Fri Feb 14 19:23:14 2014
@@ -20,10 +20,6 @@
  */
 package org.apache.qpid.server.queue;
 
-import org.apache.qpid.AMQException;
-import org.apache.qpid.server.logging.LogActor;
-import org.apache.qpid.server.logging.RootMessageLogger;
-import org.apache.qpid.server.logging.actors.CurrentActor;
 import org.apache.qpid.server.message.MessageReference;
 import org.apache.qpid.server.message.ServerMessage;
 import org.apache.qpid.server.virtualhost.VirtualHost;
@@ -51,7 +47,7 @@ public class SimpleQueueEntryImplTest ex
     }
 
 
-    public QueueEntryImpl getQueueEntryImpl(int msgId) throws AMQException
+    public QueueEntryImpl getQueueEntryImpl(int msgId)
     {
         ServerMessage message = mock(ServerMessage.class);
         when(message.getMessageNumber()).thenReturn((long)msgId);

Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryListTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryListTest.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryListTest.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryListTest.java Fri Feb 14 19:23:14 2014
@@ -20,7 +20,6 @@
 package org.apache.qpid.server.queue;
 
 import java.util.Collections;
-import org.apache.qpid.AMQException;
 import org.apache.qpid.server.logging.LogActor;
 import org.apache.qpid.server.logging.RootMessageLogger;
 import org.apache.qpid.server.logging.actors.CurrentActor;
@@ -140,7 +139,7 @@ public class SortedQueueEntryListTest ex
         return 67L;
     }
 
-    public ServerMessage getTestMessageToAdd() throws AMQException
+    public ServerMessage getTestMessageToAdd()
     {
         return generateTestMessage(1, "test value");
     }
@@ -151,7 +150,7 @@ public class SortedQueueEntryListTest ex
         return _testQueue;
     }
 
-    private ServerMessage generateTestMessage(final long id, final String keyValue) throws AMQException
+    private ServerMessage generateTestMessage(final long id, final String keyValue)
     {
         final ServerMessage message = mock(ServerMessage.class);
         AMQMessageHeader hdr = mock(AMQMessageHeader.class);

Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryTest.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryTest.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryTest.java Fri Feb 14 19:23:14 2014
@@ -22,7 +22,6 @@ package org.apache.qpid.server.queue;
 import java.util.Collections;
 import java.util.UUID;
 
-import org.apache.qpid.AMQException;
 import org.apache.qpid.server.message.AMQMessageHeader;
 import org.apache.qpid.server.message.MessageReference;
 import org.apache.qpid.server.message.ServerMessage;
@@ -56,7 +55,7 @@ public class SortedQueueEntryTest extend
         super.setUp();
     }
 
-    public QueueEntryImpl getQueueEntryImpl(int msgId) throws AMQException
+    public QueueEntryImpl getQueueEntryImpl(int msgId)
     {
         final ServerMessage message = mock(ServerMessage.class);
         AMQMessageHeader hdr = mock(AMQMessageHeader.class);

Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueEntryListTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueEntryListTest.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueEntryListTest.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueEntryListTest.java Fri Feb 14 19:23:14 2014
@@ -20,7 +20,6 @@
 */
 package org.apache.qpid.server.queue;
 
-import org.apache.qpid.AMQException;
 import org.apache.qpid.server.message.MessageReference;
 import org.apache.qpid.server.message.ServerMessage;
 import org.apache.qpid.server.virtualhost.VirtualHost;
@@ -112,7 +111,7 @@ public class StandardQueueEntryListTest 
     }
 
     @Override
-    public ServerMessage getTestMessageToAdd() throws AMQException
+    public ServerMessage getTestMessageToAdd()
     {
         ServerMessage msg = mock(ServerMessage.class);
         when(msg.getMessageNumber()).thenReturn(1l);

Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueTest.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueTest.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueTest.java Fri Feb 14 19:23:14 2014
@@ -20,8 +20,6 @@
  */
 package org.apache.qpid.server.queue;
 
-
-import org.apache.qpid.AMQException;
 import org.apache.qpid.server.consumer.Consumer;
 import org.apache.qpid.server.consumer.ConsumerTarget;
 import org.apache.qpid.server.consumer.MockConsumer;
@@ -144,7 +142,7 @@ public class StandardQueueTest extends S
     /**
      * Tests that entry in dequeued state are not enqueued and not delivered to consumer
      */
-    public void testEnqueueDequeuedEntry()
+    public void testEnqueueDequeuedEntry() throws Exception
     {
         // create a queue where each even entry is considered a dequeued
         SimpleAMQQueue queue = new DequeuedQueue(UUIDGenerator.generateRandomUUID(), "test", false,
@@ -153,19 +151,12 @@ public class StandardQueueTest extends S
         MockConsumer consumer = new MockConsumer();
 
         // register consumer
-        try
-        {
-            queue.addConsumer(consumer,
-                              null,
-                              createMessage(-1l).getClass(),
-                              "test",
-                              EnumSet.of(Consumer.Option.ACQUIRES,
-                                         Consumer.Option.SEES_REQUEUES));
-        }
-        catch (AMQException e)
-        {
-            fail("Failure to register consumer:" + e.getMessage());
-        }
+        queue.addConsumer(consumer,
+                          null,
+                          createMessage(-1l).getClass(),
+                          "test",
+                          EnumSet.of(Consumer.Option.ACQUIRES,
+                                     Consumer.Option.SEES_REQUEUES));
 
         // put test messages into a queue
         putGivenNumberOfMessages(queue, 4);
@@ -183,7 +174,7 @@ public class StandardQueueTest extends S
      * Tests whether dequeued entry is sent to subscriber in result of
      * invocation of {@link SimpleAMQQueue#processQueue(QueueRunner)}
      */
-    public void testProcessQueueWithDequeuedEntry()
+    public void testProcessQueueWithDequeuedEntry() throws Exception
     {
         // total number of messages to send
         int messageNumber = 4;
@@ -217,36 +208,30 @@ public class StandardQueueTest extends S
              * @param entry
              * @param batch
              */
-            public void send(MessageInstance entry, boolean batch) throws AMQException
+            public void send(MessageInstance entry, boolean batch)
             {
                 super.send(entry, batch);
                 latch.countDown();
             }
         };
 
-        try
-        {
-            // subscribe
-            testQueue.addConsumer(consumer,
-                                  null,
-                                  entries.get(0).getMessage().getClass(),
-                                  "test",
-                                  EnumSet.of(Consumer.Option.ACQUIRES,
-                                             Consumer.Option.SEES_REQUEUES));
+        // subscribe
+        testQueue.addConsumer(consumer,
+                              null,
+                              entries.get(0).getMessage().getClass(),
+                              "test",
+                              EnumSet.of(Consumer.Option.ACQUIRES,
+                                         Consumer.Option.SEES_REQUEUES));
 
-            // process queue
-            testQueue.processQueue(new QueueRunner(testQueue)
-            {
-                public void run()
-                {
-                    // do nothing
-                }
-            });
-        }
-        catch (AMQException e)
+        // process queue
+        testQueue.processQueue(new QueueRunner(testQueue)
         {
-            fail("Failure to process queue:" + e.getMessage());
-        }
+            public void run()
+            {
+                // do nothing
+            }
+        });
+
         // wait up to 1 minute for message receipt
         try
         {

Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java Fri Feb 14 19:23:14 2014
@@ -36,7 +36,6 @@ import java.util.Map;
 import java.util.UUID;
 
 import org.apache.commons.configuration.Configuration;
-import org.apache.qpid.AMQStoreException;
 import org.apache.qpid.common.AMQPFilterTypes;
 import org.apache.qpid.server.binding.Binding;
 import org.apache.qpid.server.exchange.Exchange;
@@ -349,7 +348,7 @@ public abstract class AbstractDurableCon
     private AMQQueue createTestQueue(String queueName,
                                      String queueOwner,
                                      boolean exclusive,
-                                     final Map<String, Object> arguments) throws AMQStoreException
+                                     final Map<String, Object> arguments) throws StoreException
     {
         return createTestQueue(queueName, queueOwner, exclusive, null, arguments);
     }
@@ -358,7 +357,7 @@ public abstract class AbstractDurableCon
                                      String queueOwner,
                                      boolean exclusive,
                                      Exchange alternateExchange,
-                                     final Map<String, Object> arguments) throws AMQStoreException
+                                     final Map<String, Object> arguments) throws StoreException
     {
         AMQQueue queue = mock(AMQQueue.class);
         when(queue.getName()).thenReturn(queueName);

Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java Fri Feb 14 19:23:14 2014
@@ -25,10 +25,11 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
-import org.apache.qpid.AMQStoreException;
+
 import org.apache.qpid.server.model.Binding;
 import org.apache.qpid.server.model.Queue;
 import org.apache.qpid.server.model.VirtualHost;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
 import org.apache.qpid.test.utils.QpidTestCase;
 import org.mockito.InOrder;
 
@@ -82,7 +83,7 @@ public class JsonFileConfigStoreTest ext
             _store.configureConfigStore(_virtualHost, _recoveryHandler);
             fail("Store should not successfully configure if there is no path set");
         }
-        catch (AMQStoreException e)
+        catch (ServerScopedRuntimeException e)
         {
             // pass
         }
@@ -97,7 +98,7 @@ public class JsonFileConfigStoreTest ext
             _store.configureConfigStore(_virtualHost, _recoveryHandler);
             fail("Store should not successfully configure if there is an invalid path set");
         }
-        catch (AMQStoreException e)
+        catch (ServerScopedRuntimeException e)
         {
             // pass
         }
@@ -197,7 +198,7 @@ public class JsonFileConfigStoreTest ext
             _store.create(UUID.randomUUID(), "wibble", Collections.<String, Object>emptyMap());
             fail("Should not be able to create instance of type wibble");
         }
-        catch (AMQStoreException e)
+        catch (StoreException e)
         {
             // pass
         }
@@ -213,7 +214,7 @@ public class JsonFileConfigStoreTest ext
             _store.create(id, "Exchange", Collections.<String, Object>emptyMap());
             fail("Should not be able to create two objects with same id");
         }
-        catch (AMQStoreException e)
+        catch (StoreException e)
         {
             // pass
         }
@@ -233,7 +234,7 @@ public class JsonFileConfigStoreTest ext
             _store.update(id, "Exchange", Collections.<String, Object>emptyMap());
             fail("Should not be able to update object to different type");
         }
-        catch (AMQStoreException e)
+        catch (StoreException e)
         {
             // pass
         }
@@ -250,7 +251,7 @@ public class JsonFileConfigStoreTest ext
             secondStore.configureConfigStore(_virtualHost, _recoveryHandler);
             fail("Should not be able to open a second store with the same path");
         }
-        catch(AMQStoreException e)
+        catch(ServerScopedRuntimeException e)
         {
             // pass
         }

Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/store/TestableMemoryMessageStore.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/store/TestableMemoryMessageStore.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/store/TestableMemoryMessageStore.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/store/TestableMemoryMessageStore.java Fri Feb 14 19:23:14 2014
@@ -20,7 +20,6 @@
  */
 package org.apache.qpid.server.store;
 
-import org.apache.qpid.AMQStoreException;
 import org.apache.qpid.server.message.EnqueueableMessage;
 import org.apache.qpid.server.queue.AMQQueue;
 
@@ -56,29 +55,29 @@ public class TestableMemoryMessageStore 
     private class TestableTransaction implements Transaction
     {
         @Override
-        public void enqueueMessage(TransactionLogResource queue, EnqueueableMessage message) throws AMQStoreException
+        public void enqueueMessage(TransactionLogResource queue, EnqueueableMessage message)
         {
             getMessages().put(message.getMessageNumber(), (AMQQueue)queue);
         }
 
         @Override
-        public void dequeueMessage(TransactionLogResource queue, EnqueueableMessage message) throws AMQStoreException
+        public void dequeueMessage(TransactionLogResource queue, EnqueueableMessage message)
         {
             getMessages().remove(message.getMessageNumber());
         }
 
         @Override
-        public void commitTran() throws AMQStoreException
+        public void commitTran()
         {
         }
 
         @Override
-        public StoreFuture commitTranAsync() throws AMQStoreException
+        public StoreFuture commitTranAsync()
         {
             return StoreFuture.IMMEDIATE_FUTURE;
         }
 
-        public void abortTran() throws AMQStoreException
+        public void abortTran()
         {
         }
 

Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/txn/MockStoreTransaction.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/txn/MockStoreTransaction.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/txn/MockStoreTransaction.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/txn/MockStoreTransaction.java Fri Feb 14 19:23:14 2014
@@ -21,13 +21,13 @@
 package org.apache.qpid.server.txn;
 
 import org.apache.commons.lang.NotImplementedException;
-import org.apache.qpid.AMQStoreException;
 import org.apache.qpid.server.message.EnqueueableMessage;
 import org.apache.qpid.server.store.MessageStore;
 import org.apache.qpid.server.store.NullMessageStore;
 import org.apache.qpid.server.store.StoreFuture;
 import org.apache.qpid.server.store.Transaction;
 import org.apache.qpid.server.store.TransactionLogResource;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
 
 /**
  * Mock implementation of a (Store) Transaction allow its state to be observed.
@@ -60,12 +60,12 @@ class MockStoreTransaction implements Tr
         return _state;
     }
 
-    public void enqueueMessage(TransactionLogResource queue, EnqueueableMessage message) throws AMQStoreException
+    public void enqueueMessage(TransactionLogResource queue, EnqueueableMessage message)
     {
         if (_throwExceptionOnQueueOp)
         {
             
-            throw new AMQStoreException("Mocked exception");
+            throw new ServerScopedRuntimeException("Mocked exception");
         }
         
         _numberOfEnqueuedMessages++;
@@ -81,27 +81,27 @@ class MockStoreTransaction implements Tr
         return _numberOfEnqueuedMessages;
     }
 
-    public void dequeueMessage(TransactionLogResource queue, EnqueueableMessage message) throws AMQStoreException
+    public void dequeueMessage(TransactionLogResource queue, EnqueueableMessage message)
     {
         if (_throwExceptionOnQueueOp)
         {
-            throw new AMQStoreException("Mocked exception");
+            throw new ServerScopedRuntimeException("Mocked exception");
         }
         
         _numberOfDequeuedMessages++;
     }
 
-    public void commitTran() throws AMQStoreException
+    public void commitTran()
     {
         _state = TransactionState.COMMITTED;
     }
 
-    public StoreFuture commitTranAsync() throws AMQStoreException
+    public StoreFuture commitTranAsync()
     {
         throw new NotImplementedException();
     }
 
-    public void abortTran() throws AMQStoreException
+    public void abortTran()
     {
         _state = TransactionState.ABORTED;
     }

Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java Fri Feb 14 19:23:14 2014
@@ -30,7 +30,6 @@ import java.util.UUID;
 
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.qpid.AMQException;
 import org.apache.qpid.server.protocol.AMQConnectionModel;
 import org.apache.qpid.server.protocol.AMQSessionModel;
 import org.apache.qpid.server.configuration.VirtualHostConfiguration;
@@ -45,7 +44,7 @@ import org.apache.qpid.server.logging.ac
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.UUIDGenerator;
 import org.apache.qpid.server.queue.AMQQueue;
-import org.apache.qpid.server.queue.AMQQueueFactory;
+import org.apache.qpid.server.security.QpidSecurityException;
 import org.apache.qpid.server.security.SecurityManager;
 import org.apache.qpid.server.security.SubjectCreator;
 import org.apache.qpid.server.stats.StatisticsGatherer;
@@ -54,6 +53,7 @@ import org.apache.qpid.server.virtualhos
 import org.apache.qpid.server.virtualhost.VirtualHost;
 import org.apache.qpid.server.plugin.VirtualHostFactory;
 import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
+import org.apache.qpid.server.virtualhost.QueueExistsException;
 
 public class BrokerTestHelper
 {
@@ -138,7 +138,7 @@ public class BrokerTestHelper
         return vhostConfig;
     }
 
-    public static AMQSessionModel createSession(int channelId, AMQConnectionModel connection) throws AMQException
+    public static AMQSessionModel createSession(int channelId, AMQConnectionModel connection)
     {
         AMQSessionModel session = mock(AMQSessionModel.class);
         when(session.getConnectionModel()).thenReturn(connection);
@@ -179,7 +179,8 @@ public class BrokerTestHelper
         return factory.createExchange("amp.direct", "direct", false, false);
     }
 
-    public static AMQQueue createQueue(String queueName, VirtualHost virtualHost) throws AMQException
+    public static AMQQueue createQueue(String queueName, VirtualHost virtualHost)
+            throws QpidSecurityException, QueueExistsException
     {
         AMQQueue queue = virtualHost.createQueue(UUIDGenerator.generateRandomUUID(), queueName, false, null,
                 false, false, false, Collections.<String, Object>emptyMap());

Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java Fri Feb 14 19:23:14 2014
@@ -27,7 +27,7 @@ import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.UUID;
-import org.apache.qpid.AMQStoreException;
+import org.apache.qpid.server.store.StoreException;
 import org.apache.qpid.server.configuration.IllegalConfigurationException;
 import org.apache.qpid.server.exchange.DirectExchange;
 import org.apache.qpid.server.exchange.Exchange;
@@ -404,7 +404,7 @@ public class DurableConfigurationRecover
         assertEquals(customExchange, _vhost.getQueue(queueId).getAlternateExchange());
     }
 
-    private void verifyCorrectUpdates(final ConfiguredObjectRecord[] expected) throws AMQStoreException
+    private void verifyCorrectUpdates(final ConfiguredObjectRecord[] expected) throws StoreException
     {
         doAnswer(new Answer()
         {

Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java Fri Feb 14 19:23:14 2014
@@ -23,7 +23,6 @@ package org.apache.qpid.server.virtualho
 import java.util.Collection;
 import java.util.Map;
 import java.util.concurrent.ScheduledFuture;
-import org.apache.qpid.AMQException;
 import org.apache.qpid.server.configuration.VirtualHostConfiguration;
 import org.apache.qpid.server.connection.IConnectionRegistry;
 import org.apache.qpid.server.exchange.Exchange;
@@ -147,7 +146,7 @@ public class MockVirtualHost implements 
     }
 
     @Override
-    public int removeQueue(AMQQueue queue) throws AMQException
+    public int removeQueue(AMQQueue queue)
     {
         return 0;
     }
@@ -160,7 +159,7 @@ public class MockVirtualHost implements 
                                 boolean autoDelete,
                                 boolean exclusive,
                                 boolean deleteOnNoConsumer,
-                                Map<String, Object> arguments) throws AMQException
+                                Map<String, Object> arguments)
     {
         return null;
     }
@@ -171,13 +170,13 @@ public class MockVirtualHost implements 
                                    String type,
                                    boolean durable,
                                    boolean autoDelete,
-                                   String alternateExchange) throws AMQException
+                                   String alternateExchange)
     {
         return null;
     }
 
     @Override
-    public void removeExchange(Exchange exchange, boolean force) throws AMQException
+    public void removeExchange(Exchange exchange, boolean force)
     {
     }
 

Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/StandardVirtualHostTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/StandardVirtualHostTest.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/StandardVirtualHostTest.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/StandardVirtualHostTest.java Fri Feb 14 19:23:14 2014
@@ -38,6 +38,7 @@ import org.apache.qpid.server.security.S
 import org.apache.qpid.server.stats.StatisticsGatherer;
 import org.apache.qpid.server.store.TestMemoryMessageStore;
 import org.apache.qpid.server.util.BrokerTestHelper;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
 import org.apache.qpid.test.utils.QpidTestCase;
 
 import java.io.BufferedWriter;
@@ -111,9 +112,11 @@ public class StandardVirtualHostTest ext
             createVirtualHost(queueName, config);
             fail("virtualhost creation should have failed due to illegal configuration");
         }
-        catch (ConfigurationException e)
+        catch (ServerScopedRuntimeException e)
         {
-            assertEquals("Illegal attempt to bind queue '" + queueName + "' to the default exchange with a key other than the queue name: " + customBinding, e.getMessage());
+            Throwable cause = e.getCause();
+            assertNotNull(cause);
+            assertEquals("Illegal attempt to bind queue '" + queueName + "' to the default exchange with a key other than the queue name: " + customBinding, cause.getMessage());
         }
     }
 
@@ -169,9 +172,11 @@ public class StandardVirtualHostTest ext
             createVirtualHost(queueName, config);
             fail("virtualhost creation should have failed due to illegal configuration");
         }
-        catch (ConfigurationException e)
+        catch (ServerScopedRuntimeException e)
         {
-            assertEquals("Attempt to bind queue '" + queueName + "' to unknown exchange:" + exchangeName, e.getMessage());
+            Throwable cause = e.getCause();
+            assertNotNull(cause);
+            assertEquals("Attempt to bind queue '" + queueName + "' to unknown exchange:" + exchangeName, cause.getMessage());
         }
     }
 

Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ConsumerTarget_0_10.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ConsumerTarget_0_10.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ConsumerTarget_0_10.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ConsumerTarget_0_10.java Fri Feb 14 19:23:14 2014
@@ -20,7 +20,6 @@
  */
 package org.apache.qpid.server.protocol.v0_10;
 
-import org.apache.qpid.AMQException;
 import org.apache.qpid.server.exchange.Exchange;
 import org.apache.qpid.server.flow.FlowCreditManager;
 import org.apache.qpid.server.logging.LogActor;
@@ -31,13 +30,13 @@ import org.apache.qpid.server.message.Se
 import org.apache.qpid.server.plugin.MessageConverter;
 import org.apache.qpid.server.protocol.MessageConverterRegistry;
 import org.apache.qpid.server.queue.AMQQueue;
-import org.apache.qpid.server.queue.QueueEntry;
 import org.apache.qpid.server.store.TransactionLogResource;
 import org.apache.qpid.server.consumer.AbstractConsumerTarget;
 import org.apache.qpid.server.consumer.Consumer;
 import org.apache.qpid.server.txn.AutoCommitTransaction;
 import org.apache.qpid.server.txn.ServerTransaction;
 import org.apache.qpid.server.util.Action;
+import org.apache.qpid.server.util.ConnectionScopedRuntimeException;
 import org.apache.qpid.transport.*;
 
 import java.util.Collections;
@@ -191,7 +190,7 @@ public class ConsumerTarget_0_10 extends
 
     private final AddMessageDispositionListenerAction _postIdSettingAction;
 
-    public void send(final MessageInstance entry, boolean batch) throws AMQException
+    public void send(final MessageInstance entry, boolean batch)
     {
         ServerMessage serverMsg = entry.getMessage();
 
@@ -507,7 +506,8 @@ public class ConsumerTarget_0_10 extends
                 _creditManager = new WindowCreditManager(0l,0l);
                 break;
             default:
-                throw new RuntimeException("Unknown message flow mode: " + flowMode);
+                // this should never happen, as 0-10 is finalised and so the enum should never change
+                throw new ConnectionScopedRuntimeException("Unknown message flow mode: " + flowMode);
         }
         _flowMode = flowMode;
         updateState(State.ACTIVE, State.SUSPENDED);
@@ -532,7 +532,7 @@ public class ConsumerTarget_0_10 extends
         }
     }
 
-    public void flush() throws AMQException
+    public void flush()
     {
         flushCreditState(true);
         getConsumer().flush();

Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageConverter_v0_10.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageConverter_v0_10.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageConverter_v0_10.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageConverter_v0_10.java Fri Feb 14 19:23:14 2014
@@ -32,6 +32,8 @@ import org.apache.qpid.server.message.Se
 import org.apache.qpid.server.plugin.MessageConverter;
 import org.apache.qpid.server.store.StoreFuture;
 import org.apache.qpid.server.store.StoredMessage;
+import org.apache.qpid.server.util.ConnectionScopedRuntimeException;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 import org.apache.qpid.transport.DeliveryProperties;
 import org.apache.qpid.transport.Header;
@@ -183,7 +185,7 @@ public class MessageConverter_v0_10 impl
             }
             catch (IOException e)
             {
-                throw new RuntimeException(e);
+                throw new ConnectionScopedRuntimeException(e);
             }
         }
     }

Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageConverter_v0_10_to_Internal.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageConverter_v0_10_to_Internal.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageConverter_v0_10_to_Internal.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageConverter_v0_10_to_Internal.java Fri Feb 14 19:23:14 2014
@@ -27,6 +27,7 @@ import org.apache.qpid.server.message.in
 import org.apache.qpid.server.plugin.MessageConverter;
 import org.apache.qpid.server.store.StoreFuture;
 import org.apache.qpid.server.store.StoredMessage;
+import org.apache.qpid.server.util.ConnectionScopedRuntimeException;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 import org.apache.qpid.transport.DeliveryProperties;
 import org.apache.qpid.transport.Header;
@@ -247,11 +248,11 @@ public class MessageConverter_v0_10_to_I
                 }
                 catch (TypedBytesFormatException e)
                 {
-                    throw new RuntimeException(e);  // TODO - Implement
+                    throw new ConnectionScopedRuntimeException(e);
                 }
                 catch (EOFException e)
                 {
-                    throw new RuntimeException(e);  // TODO - Implement
+                    throw new ConnectionScopedRuntimeException(e);  // TODO - Implement
                 }
             }
             return list;

Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerConnection.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerConnection.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerConnection.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerConnection.java Fri Feb 14 19:23:14 2014
@@ -28,13 +28,11 @@ import java.util.List;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicLong;
 import javax.security.auth.Subject;
-import org.apache.qpid.AMQException;
 import org.apache.qpid.protocol.AMQConstant;
 import org.apache.qpid.server.logging.LogActor;
 import org.apache.qpid.server.logging.LogSubject;
 import org.apache.qpid.server.logging.actors.AMQPConnectionActor;
 import org.apache.qpid.server.logging.actors.CurrentActor;
-import org.apache.qpid.server.logging.actors.GenericActor;
 import org.apache.qpid.server.logging.messages.ConnectionMessages;
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.Port;
@@ -44,6 +42,7 @@ import org.apache.qpid.server.protocol.A
 import org.apache.qpid.server.security.AuthorizationHolder;
 import org.apache.qpid.server.security.auth.AuthenticatedPrincipal;
 import org.apache.qpid.server.stats.StatisticsCounter;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 import org.apache.qpid.transport.Connection;
 import org.apache.qpid.transport.ConnectionCloseCode;
@@ -52,7 +51,6 @@ import org.apache.qpid.transport.Executi
 import org.apache.qpid.transport.Method;
 import org.apache.qpid.transport.ProtocolEvent;
 import org.apache.qpid.transport.Session;
-import org.apache.qpid.transport.network.NetworkConnection;
 
 import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.CONNECTION_FORMAT;
 import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.SOCKET_FORMAT;
@@ -199,7 +197,7 @@ public class ServerConnection extends Co
         _onOpenTask = task;
     }
 
-    public void closeSession(AMQSessionModel session, AMQConstant cause, String message) throws AMQException
+    public void closeSession(AMQSessionModel session, AMQConstant cause, String message)
     {
         ExecutionException ex = new ExecutionException();
         ExecutionErrorCode code = ExecutionErrorCode.INTERNAL_ERROR;
@@ -215,12 +213,32 @@ public class ServerConnection extends Co
         ex.setDescription(message);
         ((ServerSession)session).invoke(ex);
 
-        ((ServerSession)session).close(cause, message);
+        session.close(cause, message);
     }
 
     public LogSubject getLogSubject()
     {
-        return (LogSubject) this;
+        return this;
+    }
+
+    @Override
+    public void exception(final Throwable t)
+    {
+        try
+        {
+            super.exception(t);
+        }
+        finally
+        {
+            if(t instanceof Error)
+            {
+                throw (Error) t;
+            }
+            if(t instanceof ServerScopedRuntimeException)
+            {
+                throw (ServerScopedRuntimeException) t;
+            }
+        }
     }
 
     @Override
@@ -294,7 +312,7 @@ public class ServerConnection extends Co
         return _actor;
     }
 
-    public void close(AMQConstant cause, String message) throws AMQException
+    public void close(AMQConstant cause, String message)
     {
         closeSubscriptions();
         ConnectionCloseCode replyCode = ConnectionCloseCode.NORMAL;

Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSession.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSession.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSession.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSession.java Fri Feb 14 19:23:14 2014
@@ -41,8 +41,7 @@ import java.util.concurrent.atomic.Atomi
 import java.util.concurrent.atomic.AtomicReference;
 
 import javax.security.auth.Subject;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.AMQStoreException;
+import org.apache.qpid.server.store.StoreException;
 import org.apache.qpid.protocol.AMQConstant;
 import org.apache.qpid.server.TransactionTimeoutHelper;
 import org.apache.qpid.server.TransactionTimeoutHelper.CloseAction;
@@ -148,7 +147,7 @@ public class ServerSession extends Sessi
         _transactionTimeoutHelper = new TransactionTimeoutHelper(_logSubject, new CloseAction()
         {
             @Override
-            public void doTimeoutAction(String reason) throws AMQException
+            public void doTimeoutAction(String reason)
             {
                 getConnectionModel().closeSession(ServerSession.this, AMQConstant.RESOURCE_ERROR, reason);
             }
@@ -493,14 +492,14 @@ public class ServerSession extends Sessi
 
     public void prepareDtx(Xid xid)
             throws UnknownDtxBranchException,
-            IncorrectDtxStateException, AMQStoreException, RollbackOnlyDtxException, TimeoutDtxException
+            IncorrectDtxStateException, StoreException, RollbackOnlyDtxException, TimeoutDtxException
     {
         getVirtualHost().getDtxRegistry().prepare(xid);
     }
 
     public void commitDtx(Xid xid, boolean onePhase)
             throws UnknownDtxBranchException,
-            IncorrectDtxStateException, AMQStoreException, RollbackOnlyDtxException, TimeoutDtxException
+            IncorrectDtxStateException, StoreException, RollbackOnlyDtxException, TimeoutDtxException
     {
         getVirtualHost().getDtxRegistry().commit(xid, onePhase);
     }
@@ -508,7 +507,7 @@ public class ServerSession extends Sessi
 
     public void rollbackDtx(Xid xid)
             throws UnknownDtxBranchException,
-            IncorrectDtxStateException, AMQStoreException, TimeoutDtxException
+            IncorrectDtxStateException, StoreException, TimeoutDtxException
     {
         getVirtualHost().getDtxRegistry().rollback(xid);
     }
@@ -679,7 +678,7 @@ public class ServerSession extends Sessi
         return (LogSubject) this;
     }
 
-    public void checkTransactionStatus(long openWarn, long openClose, long idleWarn, long idleClose) throws AMQException
+    public void checkTransactionStatus(long openWarn, long openClose, long idleWarn, long idleClose)
     {
         _transactionTimeoutHelper.checkIdleOrOpenTimes(_transaction, openWarn, openClose, idleWarn, idleClose);
     }

Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegate.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegate.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegate.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegate.java Fri Feb 14 19:23:14 2014
@@ -25,12 +25,11 @@ import java.util.LinkedHashMap;
 import java.util.UUID;
 import org.apache.log4j.Logger;
 
-import org.apache.qpid.AMQException;
-import org.apache.qpid.AMQStoreException;
-import org.apache.qpid.AMQUnknownExchangeType;
+import org.apache.qpid.server.store.StoreException;
+import org.apache.qpid.server.exchange.AMQUnknownExchangeType;
 import org.apache.qpid.server.exchange.Exchange;
-import org.apache.qpid.server.exchange.ExchangeInUseException;
 import org.apache.qpid.server.exchange.HeadersExchange;
+import org.apache.qpid.server.filter.AMQInvalidArgumentException;
 import org.apache.qpid.server.filter.FilterManager;
 import org.apache.qpid.server.filter.FilterManagerFactory;
 import org.apache.qpid.server.logging.messages.ExchangeMessages;
@@ -43,6 +42,7 @@ import org.apache.qpid.server.model.UUID
 import org.apache.qpid.server.plugin.ExchangeType;
 import org.apache.qpid.server.queue.AMQQueue;
 import org.apache.qpid.server.queue.QueueArgumentsConverter;
+import org.apache.qpid.server.security.QpidSecurityException;
 import org.apache.qpid.server.security.SecurityManager;
 import org.apache.qpid.server.store.DurableConfigurationStore;
 import org.apache.qpid.server.store.MessageStore;
@@ -66,7 +66,7 @@ import org.apache.qpid.server.virtualhos
 import org.apache.qpid.server.virtualhost.ReservedExchangeNameException;
 import org.apache.qpid.server.virtualhost.UnknownExchangeException;
 import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.server.virtualhost.plugins.QueueExistsException;
+import org.apache.qpid.server.virtualhost.QueueExistsException;
 import org.apache.qpid.transport.*;
 
 import java.nio.ByteBuffer;
@@ -253,7 +253,7 @@ public class ServerSessionDelegate exten
                     {
                         filterManager = FilterManagerFactory.createManager(method.getArguments());
                     }
-                    catch (AMQException amqe)
+                    catch (AMQInvalidArgumentException amqe)
                     {
                         exception(session, method, ExecutionErrorCode.ILLEGAL_ARGUMENT, "Exception Creating FilterManager");
                         return;
@@ -298,9 +298,9 @@ public class ServerSessionDelegate exten
                     {
                         exception(session, method, ExecutionErrorCode.RESOURCE_LOCKED, "Queue has an existing consumer - can't subscribe exclusively");
                     }
-                    catch (AMQException e)
+                    catch (QpidSecurityException e)
                     {
-                        exception(session, method, e, "Cannot subscribe to queue '" + queueName + "' with destination '" + destination);
+                        exception(session, method, ExecutionErrorCode.UNAUTHORIZED_ACCESS, e.getMessage());
                     }
                 }
             }
@@ -431,15 +431,7 @@ public class ServerSessionDelegate exten
         }
         else
         {
-
-            try
-            {
-                sub.flush();
-            }
-            catch (AMQException e)
-            {
-                exception(session, method, e, "Cannot flush subscription '" + destination);
-            }
+            sub.flush();
         }
     }
 
@@ -566,9 +558,10 @@ public class ServerSessionDelegate exten
         {
             exception(session, method, ExecutionErrorCode.ILLEGAL_STATE, e.getMessage());
         }
-        catch(AMQStoreException e)
+        catch(StoreException e)
         {
             exception(session, method, ExecutionErrorCode.INTERNAL_ERROR, e.getMessage());
+            throw e;
         }
     }
 
@@ -634,9 +627,10 @@ public class ServerSessionDelegate exten
         {
             exception(session, method, ExecutionErrorCode.ILLEGAL_STATE, e.getMessage());
         }
-        catch(AMQStoreException e)
+        catch(StoreException e)
         {
             exception(session, method, ExecutionErrorCode.INTERNAL_ERROR, e.getMessage());
+            throw e;
         }
     }
 
@@ -675,9 +669,10 @@ public class ServerSessionDelegate exten
         {
             exception(session, method, ExecutionErrorCode.ILLEGAL_STATE, e.getMessage());
         }
-        catch(AMQStoreException e)
+        catch(StoreException e)
         {
             exception(session, method, ExecutionErrorCode.INTERNAL_ERROR, e.getMessage());
+            throw e;
         }
     }
 
@@ -783,9 +778,9 @@ public class ServerSessionDelegate exten
                                     + " to " + method.getAlternateExchange() +".");
                 }
             }
-            catch (AMQException e)
+            catch (QpidSecurityException e)
             {
-                exception(session, method, e, "Cannot declare exchange '" + exchangeName);
+                exception(session, method, ExecutionErrorCode.UNAUTHORIZED_ACCESS, e.getMessage());
             }
 
 
@@ -793,26 +788,6 @@ public class ServerSessionDelegate exten
 
     }
 
-    // TODO decouple AMQException and AMQConstant error codes
-    private void exception(Session session, Method method, AMQException exception, String message)
-    {
-        ExecutionErrorCode errorCode = ExecutionErrorCode.INTERNAL_ERROR;
-        if (exception.getErrorCode() != null)
-        {
-            try
-            {
-                errorCode = ExecutionErrorCode.get(exception.getErrorCode().getCode());
-            }
-            catch (IllegalArgumentException iae)
-            {
-                // ignore, already set to INTERNAL_ERROR
-            }
-        }
-        String description = message + "': " + exception.getMessage();
-
-        exception(session, method, errorCode, description);
-    }
-
     private void exception(Session session, Method method, ExecutionErrorCode errorCode, String description)
     {
         ExecutionException ex = new ExecutionException();
@@ -887,10 +862,6 @@ public class ServerSessionDelegate exten
                 virtualHost.removeExchange(exchange, !method.getIfUnused());
             }
         }
-        catch (ExchangeInUseException e)
-        {
-            exception(session, method, ExecutionErrorCode.PRECONDITION_FAILED, "Exchange in use");
-        }
         catch (ExchangeIsAlternateException e)
         {
             exception(session, method, ExecutionErrorCode.NOT_ALLOWED, "Exchange in use as an alternate exchange");
@@ -899,9 +870,9 @@ public class ServerSessionDelegate exten
         {
             exception(session, method, ExecutionErrorCode.NOT_ALLOWED, "Exchange '"+method.getExchange()+"' cannot be deleted");
         }
-        catch (AMQException e)
+        catch (QpidSecurityException e)
         {
-            exception(session, method, e, "Cannot delete exchange '" + method.getExchange() );
+            exception(session, method, ExecutionErrorCode.UNAUTHORIZED_ACCESS, e.getMessage());
         }
     }
 
@@ -993,9 +964,9 @@ public class ServerSessionDelegate exten
                     {
                         exchange.addBinding(method.getBindingKey(), queue, method.getArguments());
                     }
-                    catch (AMQException e)
+                    catch (QpidSecurityException e)
                     {
-                        exception(session, method, e, "Cannot add binding '" + method.getBindingKey());
+                        exception(session, method, ExecutionErrorCode.UNAUTHORIZED_ACCESS, e.getMessage());
                     }
                 }
                 else
@@ -1046,9 +1017,9 @@ public class ServerSessionDelegate exten
                 {
                     exchange.removeBinding(method.getBindingKey(), queue, null);
                 }
-                catch (AMQException e)
+                catch (QpidSecurityException e)
                 {
-                    exception(session, method, e, "Cannot remove binding '" + method.getBindingKey());
+                    exception(session, method, ExecutionErrorCode.UNAUTHORIZED_ACCESS, e.getMessage());
                 }
             }
         }
@@ -1273,9 +1244,9 @@ public class ServerSessionDelegate exten
                                 {
                                     virtualHost.removeQueue(q);
                                 }
-                                catch (AMQException e)
+                                catch (QpidSecurityException e)
                                 {
-                                    exception(session, method, e, "Cannot delete '" + method.getQueue());
+                                    exception(session, method, ExecutionErrorCode.UNAUTHORIZED_ACCESS, e.getMessage());
                                 }
                             }
                         };
@@ -1325,9 +1296,9 @@ public class ServerSessionDelegate exten
                     exception(session, method, errorCode, description);
                 }
             }
-            catch (AMQException e)
+            catch (QpidSecurityException e)
             {
-                exception(session, method, e, "Cannot declare queue '" + queueName);
+                exception(session, method, ExecutionErrorCode.UNAUTHORIZED_ACCESS, e.getMessage());
             }
         }
     }
@@ -1402,9 +1373,9 @@ public class ServerSessionDelegate exten
                     {
                         virtualHost.removeQueue(queue);
                     }
-                    catch (AMQException e)
+                    catch (QpidSecurityException e)
                     {
-                        exception(session, method, e, "Cannot delete queue '" + queueName);
+                        exception(session, method, ExecutionErrorCode.UNAUTHORIZED_ACCESS, e.getMessage());
                     }
                 }
             }
@@ -1433,9 +1404,9 @@ public class ServerSessionDelegate exten
                 {
                     queue.clearQueue();
                 }
-                catch (AMQException e)
+                catch (QpidSecurityException e)
                 {
-                    exception(session, method, e, "Cannot purge queue '" + queueName);
+                    exception(session, method, ExecutionErrorCode.UNAUTHORIZED_ACCESS, e.getMessage());
                 }
             }
         }

Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java Fri Feb 14 19:23:14 2014
@@ -29,7 +29,8 @@ import java.util.concurrent.locks.Lock;
 import org.apache.log4j.Logger;
 import org.apache.qpid.AMQConnectionException;
 import org.apache.qpid.AMQException;
-import org.apache.qpid.AMQSecurityException;
+import org.apache.qpid.server.filter.AMQInvalidArgumentException;
+import org.apache.qpid.server.security.QpidSecurityException;
 import org.apache.qpid.common.AMQPFilterTypes;
 import org.apache.qpid.framing.AMQMethodBody;
 import org.apache.qpid.framing.AMQShortString;
@@ -81,6 +82,7 @@ import org.apache.qpid.server.txn.LocalT
 import org.apache.qpid.server.txn.LocalTransaction.ActivityTimeAccessor;
 import org.apache.qpid.server.txn.ServerTransaction;
 import org.apache.qpid.server.util.Action;
+import org.apache.qpid.server.util.ConnectionScopedRuntimeException;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 import org.apache.qpid.transport.TransportException;
 
@@ -186,9 +188,16 @@ public class AMQChannel implements AMQSe
         _transactionTimeoutHelper = new TransactionTimeoutHelper(_logSubject, new CloseAction()
         {
             @Override
-            public void doTimeoutAction(String reason) throws AMQException
+            public void doTimeoutAction(String reason)
             {
-                closeConnection(reason);
+                try
+                {
+                    closeConnection(reason);
+                }
+                catch (AMQException e)
+                {
+                    throw new ConnectionScopedRuntimeException(e);
+                }
             }
         });
     }
@@ -262,13 +271,13 @@ public class AMQChannel implements AMQSe
         return _channelId;
     }
 
-    public void setPublishFrame(MessagePublishInfo info, final MessageDestination e) throws AMQSecurityException
+    public void setPublishFrame(MessagePublishInfo info, final MessageDestination e) throws QpidSecurityException
     {
         String routingKey = info.getRoutingKey() == null ? null : info.getRoutingKey().asString();
         SecurityManager securityManager = getVirtualHost().getSecurityManager();
         if (!securityManager.authorisePublish(info.isImmediate(), routingKey, e.getName()))
         {
-            throw new AMQSecurityException("Permission denied: " + e.getName());
+            throw new QpidSecurityException("Permission denied: " + e.getName());
         }
         _currentMessage = new IncomingMessage(info);
         _currentMessage.setMessageDestination(e);
@@ -515,7 +524,9 @@ public class AMQChannel implements AMQSe
      * @throws AMQException                  if something goes wrong
      */
     public AMQShortString consumeFromSource(AMQShortString tag, MessageSource source, boolean acks,
-                                            FieldTable filters, boolean exclusive, boolean noLocal) throws AMQException
+                                            FieldTable filters, boolean exclusive, boolean noLocal)
+            throws AMQException, QpidSecurityException, MessageSource.ExistingConsumerPreventsExclusive,
+                   MessageSource.ExistingExclusiveConsumer, AMQInvalidArgumentException
     {
         if (tag == null)
         {
@@ -578,12 +589,22 @@ public class AMQChannel implements AMQSe
                                       AMQShortString.toString(tag),
                                       options);
         }
-        catch (AMQException e)
+        catch (QpidSecurityException e)
         {
             _tag2SubscriptionTargetMap.remove(tag);
             throw e;
         }
-        catch (RuntimeException e)
+        catch (MessageSource.ExistingExclusiveConsumer e)
+        {
+            _tag2SubscriptionTargetMap.remove(tag);
+            throw e;
+        }
+        catch (MessageSource.ExistingConsumerPreventsExclusive e)
+        {
+            _tag2SubscriptionTargetMap.remove(tag);
+            throw e;
+        }
+        catch (AMQInvalidArgumentException e)
         {
             _tag2SubscriptionTargetMap.remove(tag);
             throw e;
@@ -595,9 +616,8 @@ public class AMQChannel implements AMQSe
      * Unsubscribe a consumer from a queue.
      * @param consumerTag
      * @return true if the consumerTag had a mapped queue that could be unregistered.
-     * @throws AMQException
      */
-    public boolean unsubscribeConsumer(AMQShortString consumerTag) throws AMQException
+    public boolean unsubscribeConsumer(AMQShortString consumerTag)
     {
 
         ConsumerTarget_0_8 target = _tag2SubscriptionTargetMap.remove(consumerTag);
@@ -616,16 +636,14 @@ public class AMQChannel implements AMQSe
 
     /**
      * Called from the protocol session to close this channel and clean up. T
-     *
-     * @throws AMQException if there is an error during closure
      */
     @Override
-    public void close() throws AMQException
+    public void close()
     {
         close(null, null);
     }
 
-    public void close(AMQConstant cause, String message) throws AMQException
+    public void close(AMQConstant cause, String message)
     {
         if(!_closing.compareAndSet(false, true))
         {
@@ -645,17 +663,13 @@ public class AMQChannel implements AMQSe
         {
             requeue();
         }
-        catch (AMQException e)
-        {
-            _logger.error("Caught AMQException whilst attempting to requeue:" + e);
-        }
         catch (TransportException e)
         {
             _logger.error("Caught TransportException whilst attempting to requeue:" + e);
         }
     }
 
-    private void unsubscribeAllConsumers() throws AMQException
+    private void unsubscribeAllConsumers()
     {
         if (_logger.isInfoEnabled())
         {
@@ -718,9 +732,8 @@ public class AMQChannel implements AMQSe
      * Called to attempt re-delivery all outstanding unacknowledged messages on the channel. May result in delivery to
      * this same channel or to other subscribers.
      *
-     * @throws org.apache.qpid.AMQException if the requeue fails
      */
-    public void requeue() throws AMQException
+    public void requeue()
     {
         // we must create a new map since all the messages will get a new delivery tag when they are redelivered
         Collection<MessageInstance> messagesToBeDelivered = _unacknowledgedMessageMap.cancelAllMessages();
@@ -750,9 +763,8 @@ public class AMQChannel implements AMQSe
      *
      * @param deliveryTag The message to requeue
      *
-     * @throws AMQException If something goes wrong.
      */
-    public void requeue(long deliveryTag) throws AMQException
+    public void requeue(long deliveryTag)
     {
         MessageInstance unacked = _unacknowledgedMessageMap.remove(deliveryTag);
 
@@ -1228,23 +1240,16 @@ public class AMQChannel implements AMQSe
                                     @Override
                                     public void postCommit()
                                     {
-                                        try
-                                        {
-                                            final
-                                            ProtocolOutputConverter outputConverter =
+                                        final ProtocolOutputConverter outputConverter =
                                                     _session.getProtocolOutputConverter();
 
-                                            outputConverter.writeReturn(message.getMessagePublishInfo(),
-                                                                        message.getContentHeaderBody(),
-                                                                        message,
-                                                                        _channelId,
-                                                                        AMQConstant.NO_CONSUMERS.getCode(),
-                                                                        IMMEDIATE_DELIVERY_REPLY_TEXT);
-                                        }
-                                        catch (AMQException e)
-                                        {
-                                            throw new RuntimeException(e);
-                                        }
+                                        outputConverter.writeReturn(message.getMessagePublishInfo(),
+                                                                    message.getContentHeaderBody(),
+                                                                    message,
+                                                                    _channelId,
+                                                                    AMQConstant.NO_CONSUMERS.getCode(),
+                                                                    IMMEDIATE_DELIVERY_REPLY_TEXT);
+
                                     }
 
                                     @Override
@@ -1354,23 +1359,14 @@ public class AMQChannel implements AMQSe
 
         public void postCommit()
         {
-            try
-            {
-                AMQMessage message = _reference.getMessage();
-                _session.getProtocolOutputConverter().writeReturn(message.getMessagePublishInfo(),
-                                                              message.getContentHeaderBody(),
-                                                              message,
-                                                              _channelId,
-                                                              _errorCode.getCode(),
-                                                              AMQShortString.validValueOf(_description));
-                _reference.release();
-            }
-            catch (AMQException e)
-            {
-                //TODO
-                throw new RuntimeException(e);
-            }
-
+            AMQMessage message = _reference.getMessage();
+            _session.getProtocolOutputConverter().writeReturn(message.getMessagePublishInfo(),
+                                                          message.getContentHeaderBody(),
+                                                          message,
+                                                          _channelId,
+                                                          _errorCode.getCode(),
+                                                          AMQShortString.validValueOf(_description));
+            _reference.release();
         }
 
         public void onRollback()
@@ -1465,7 +1461,7 @@ public class AMQChannel implements AMQSe
         return getProtocolSession().getVirtualHost();
     }
 
-    public void checkTransactionStatus(long openWarn, long openClose, long idleWarn, long idleClose) throws AMQException
+    public void checkTransactionStatus(long openWarn, long openClose, long idleWarn, long idleClose)
     {
         _transactionTimeoutHelper.checkIdleOrOpenTimes(_transaction, openWarn, openClose, idleWarn, idleClose);
     }

Modified: qpid/branches/java-broker-amqp-1-0-management/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/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngine.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngine.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngine.java Fri Feb 14 19:23:14 2014
@@ -46,28 +46,11 @@ import org.apache.log4j.Logger;
 import org.apache.qpid.AMQChannelException;
 import org.apache.qpid.AMQConnectionException;
 import org.apache.qpid.AMQException;
-import org.apache.qpid.AMQSecurityException;
+import org.apache.qpid.framing.*;
+import org.apache.qpid.server.security.QpidSecurityException;
 import org.apache.qpid.codec.AMQCodecFactory;
 import org.apache.qpid.common.QpidProperties;
 import org.apache.qpid.common.ServerPropertyNames;
-import org.apache.qpid.framing.AMQBody;
-import org.apache.qpid.framing.AMQDataBlock;
-import org.apache.qpid.framing.AMQFrame;
-import org.apache.qpid.framing.AMQMethodBody;
-import org.apache.qpid.framing.AMQProtocolHeaderException;
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.framing.ChannelCloseBody;
-import org.apache.qpid.framing.ChannelCloseOkBody;
-import org.apache.qpid.framing.ConnectionCloseBody;
-import org.apache.qpid.framing.ContentBody;
-import org.apache.qpid.framing.ContentHeaderBody;
-import org.apache.qpid.framing.FieldTable;
-import org.apache.qpid.framing.FieldTableFactory;
-import org.apache.qpid.framing.HeartbeatBody;
-import org.apache.qpid.framing.MethodDispatcher;
-import org.apache.qpid.framing.MethodRegistry;
-import org.apache.qpid.framing.ProtocolInitiation;
-import org.apache.qpid.framing.ProtocolVersion;
 import org.apache.qpid.properties.ConnectionStartProperties;
 import org.apache.qpid.protocol.AMQConstant;
 import org.apache.qpid.protocol.AMQMethodEvent;
@@ -95,6 +78,8 @@ import org.apache.qpid.server.protocol.v
 import org.apache.qpid.server.protocol.v0_8.state.AMQStateManager;
 import org.apache.qpid.server.stats.StatisticsCounter;
 import org.apache.qpid.server.consumer.Consumer;
+import org.apache.qpid.server.util.ConnectionScopedRuntimeException;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 import org.apache.qpid.transport.Sender;
 import org.apache.qpid.transport.TransportException;
@@ -303,9 +288,24 @@ public class AMQProtocolEngine implement
             }
             receivedComplete();
         }
-        catch (Exception e)
+        catch (ConnectionScopedRuntimeException e)
+        {
+            _logger.error("Unexpected exception", e);
+            closeProtocolSession();
+        }
+        catch (AMQProtocolVersionException e)
+        {
+            _logger.error("Unexpected protocol version", e);
+            closeProtocolSession();
+        }
+        catch (AMQFrameDecodingException e)
         {
-            _logger.error("Unexpected exception when processing datablocks", e);
+            _logger.error("Frame decoding", e);
+            closeProtocolSession();
+        }
+        catch (IOException e)
+        {
+            _logger.error("I/O Exception", e);
             closeProtocolSession();
         }
         finally
@@ -314,34 +314,14 @@ public class AMQProtocolEngine implement
         }
     }
 
-    private void receivedComplete() throws AMQException
+    private void receivedComplete()
     {
-        Exception exception = null;
         for (AMQChannel channel : _channelsForCurrentMessage)
         {
-            try
-            {
-                channel.receivedComplete();
-            }
-            catch(Exception exceptionForThisChannel)
-            {
-                if(exception == null)
-                {
-                    exception = exceptionForThisChannel;
-                }
-                _logger.error("Error informing channel that receiving is complete. Channel: " + channel, exceptionForThisChannel);
-            }
+            channel.receivedComplete();
         }
 
         _channelsForCurrentMessage.clear();
-
-        if(exception != null)
-        {
-            throw new AMQException(
-                    AMQConstant.INTERNAL_ERROR,
-                    "Error informing channel that receiving is complete: " + exception.getMessage(),
-                    exception);
-        }
     }
 
     /**
@@ -549,7 +529,7 @@ public class AMQProtocolEngine implement
         }
         catch (IOException e)
         {
-            throw new RuntimeException(e);
+            throw new ServerScopedRuntimeException(e);
         }
 
         final ByteBuffer buf;
@@ -628,12 +608,6 @@ public class AMQProtocolEngine implement
                 _logger.info(e.getMessage() + " whilst processing:" + methodBody);
                 closeConnection(channelId, e);
             }
-            catch (AMQSecurityException e)
-            {
-                AMQConnectionException ce = evt.getMethod().getConnectionException(AMQConstant.ACCESS_REFUSED, e.getMessage());
-                _logger.info(e.getMessage() + " whilst processing:" + methodBody);
-                closeConnection(channelId, ce);
-            }
         }
         catch (Exception e)
         {
@@ -818,16 +792,15 @@ public class AMQProtocolEngine implement
      *
      * @param channelId id of the channel to close
      *
-     * @throws AMQException             if an error occurs closing the channel
      * @throws IllegalArgumentException if the channel id is not valid
      */
     @Override
-    public void closeChannel(int channelId) throws AMQException
+    public void closeChannel(int channelId)
     {
         closeChannel(channelId, null, null);
     }
 
-    public void closeChannel(int channelId, AMQConstant cause, String message) throws AMQException
+    public void closeChannel(int channelId, AMQConstant cause, String message)
     {
         final AMQChannel channel = getChannel(channelId);
         if (channel == null)
@@ -909,7 +882,7 @@ public class AMQProtocolEngine implement
      *
      * @throws AMQException if an error occurs while closing any channel
      */
-    private void closeAllChannels() throws AMQException
+    private void closeAllChannels()
     {
         for (AMQChannel channel : getChannels())
         {
@@ -927,7 +900,7 @@ public class AMQProtocolEngine implement
 
     /** This must be called when the session is _closed in order to free up any resources managed by the session. */
     @Override
-    public void closeSession() throws AMQException
+    public void closeSession()
     {
         if(_closing.compareAndSet(false,true))
         {
@@ -1002,7 +975,7 @@ public class AMQProtocolEngine implement
         }
     }
 
-    private void closeConnection(int channelId, AMQConnectionException e) throws AMQException
+    private void closeConnection(int channelId, AMQConnectionException e)
     {
         try
         {
@@ -1039,7 +1012,7 @@ public class AMQProtocolEngine implement
         {
             _stateManager.changeState(AMQState.CONNECTION_CLOSED);
         }
-        catch (AMQException e)
+        catch (ConnectionScopedRuntimeException e)
         {
             _logger.info(e.getMessage());
         }
@@ -1240,9 +1213,9 @@ public class AMQProtocolEngine implement
                 closeProtocolSession();
             }
         }
-        catch (AMQException e)
+        catch (ConnectionScopedRuntimeException e)
         {
-           _logger.error("Could not close protocol engine", e);
+            _logger.error("Could not close protocol engine", e);
         }
         catch (TransportException e)
         {
@@ -1275,15 +1248,30 @@ public class AMQProtocolEngine implement
         }
         else
         {
-            _logger.error("Exception caught in " + this + ", closing connection explicitly: " + throwable, throwable);
+            try
+            {
+                _logger.error("Exception caught in " + this + ", closing connection explicitly: " + throwable, throwable);
 
 
-            MethodRegistry methodRegistry = MethodRegistry.getMethodRegistry(getProtocolVersion());
-            ConnectionCloseBody closeBody = methodRegistry.createConnectionCloseBody(200,new AMQShortString(throwable.getMessage()),0,0);
+                MethodRegistry methodRegistry = MethodRegistry.getMethodRegistry(getProtocolVersion());
+                ConnectionCloseBody closeBody = methodRegistry.createConnectionCloseBody(200,new AMQShortString(throwable.getMessage()),0,0);
 
-            writeFrame(closeBody.generateFrame(0));
+                writeFrame(closeBody.generateFrame(0));
 
-            _sender.close();
+                _sender.close();
+            }
+            finally
+            {
+                if(throwable instanceof Error)
+                {
+                    throw (Error) throwable;
+                }
+                if(throwable instanceof ServerScopedRuntimeException)
+                {
+                    throw (ServerScopedRuntimeException) throwable;
+                }
+
+            }
         }
     }
 
@@ -1447,15 +1435,8 @@ public class AMQProtocolEngine implement
         {
             writeFrame(responseBody.generateFrame(0));
 
-            try
-            {
+            closeSession();
 
-                closeSession();
-            }
-            catch (AMQException ex)
-            {
-                throw new RuntimeException(ex);
-            }
         }
         finally
         {
@@ -1489,15 +1470,7 @@ public class AMQProtocolEngine implement
         try
         {
             writeFrame(responseBody.generateFrame(channelId));
-
-            try
-            {
-                closeChannel(channelId);
-            }
-            catch (AMQException ex)
-            {
-                throw new RuntimeException(ex);
-            }
+            closeChannel(channelId);
         }
         finally
         {
@@ -1513,7 +1486,7 @@ public class AMQProtocolEngine implement
         return getContextKey().toString();
     }
 
-    public void closeSession(AMQSessionModel session, AMQConstant cause, String message) throws AMQException
+    public void closeSession(AMQSessionModel session, AMQConstant cause, String message)
     {
         int channelId = ((AMQChannel)session).getChannelId();
         closeChannel(channelId, cause, message);
@@ -1528,7 +1501,7 @@ public class AMQProtocolEngine implement
         writeFrame(responseBody.generateFrame(channelId));
     }
 
-    public void close(AMQConstant cause, String message) throws AMQException
+    public void close(AMQConstant cause, String message)
     {
         closeConnection(0, new AMQConnectionException(cause, message, 0, 0,
 		                getProtocolOutputConverter().getProtocolMajorVersion(),
@@ -1670,7 +1643,6 @@ public class AMQProtocolEngine implement
         @Override
         public void deliverToClient(final Consumer sub, final ServerMessage message,
                                     final InstanceProperties props, final long deliveryTag)
-                throws AMQException
         {
             registerMessageDelivered(message.getSize());
             _protocolOutputConverter.writeDeliver(message,

Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolSession.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolSession.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolSession.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolSession.java Fri Feb 14 19:23:14 2014
@@ -71,7 +71,7 @@ public interface AMQProtocolSession exte
 
     public static interface Task
     {
-        public void doTask(AMQProtocolSession session) throws AMQException;
+        public void doTask(AMQProtocolSession session);
     }
 
     /**
@@ -152,7 +152,7 @@ public interface AMQProtocolSession exte
     void initHeartbeats(int delay);
 
     /** This must be called when the session is _closed in order to free up any resources managed by the session. */
-    void closeSession() throws AMQException;
+    void closeSession();
 
     void closeProtocolSession();
 

Modified: qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/ClientDeliveryMethod.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/ClientDeliveryMethod.java?rev=1568495&r1=1568494&r2=1568495&view=diff
==============================================================================
--- qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/ClientDeliveryMethod.java (original)
+++ qpid/branches/java-broker-amqp-1-0-management/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/ClientDeliveryMethod.java Fri Feb 14 19:23:14 2014
@@ -28,5 +28,5 @@ import org.apache.qpid.server.consumer.C
 public interface ClientDeliveryMethod
 {
     void deliverToClient(final Consumer sub, final ServerMessage message, final InstanceProperties props,
-                         final long deliveryTag) throws AMQException;
+                         final long deliveryTag);
 }



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