summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Godfrey <rgodfrey@apache.org>2014-02-14 19:23:14 +0000
committerRobert Godfrey <rgodfrey@apache.org>2014-02-14 19:23:14 +0000
commite31aa33452bd54ce118078ad38d8291cc3a3d1db (patch)
tree208074a516facfe5db4f0e45239a071755427cbe
parent4487d5b68a5d91abf66406bdc730806d70f1c325 (diff)
downloadqpid-python-e31aa33452bd54ce118078ad38d8291cc3a3d1db.tar.gz
Merged from trunk
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/java-broker-amqp-1-0-management@1568495 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ConnectionEndpoint.java12
-rw-r--r--java/bdbstore/jmx/src/main/java/org/apache/qpid/server/store/berkeleydb/jmx/BDBHAMessageStoreManagerMBean.java8
-rw-r--r--java/bdbstore/jmx/src/test/java/org/apache/qpid/server/store/berkeleydb/jmx/BDBHAMessageStoreManagerMBeanTest.java8
-rw-r--r--java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java219
-rw-r--r--java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBBackup.java11
-rw-r--r--java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBHAMessageStore.java45
-rw-r--r--java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHost.java12
-rw-r--r--java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHostFactory.java2
-rw-r--r--java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java15
-rw-r--r--java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/CommitThreadWrapper.java3
-rw-r--r--java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/FieldTableEncoding.java3
-rw-r--r--java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuple/ConfiguredObjectBinding.java9
-rw-r--r--java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/StoreUpgrade.java5
-rw-r--r--java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom4To5.java51
-rw-r--r--java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom5To6.java68
-rw-r--r--java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom6To7.java6
-rw-r--r--java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/Upgrader.java20
-rw-r--r--java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/HAMessageStoreSmokeTest.java3
-rw-r--r--java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgraderFailOnNewerVersionTest.java12
-rw-r--r--java/bdbstore/systests/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreTest.java4
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/TransactionTimeoutHelper.java7
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java3
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/StoreConfigurationChangeListener.java5
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/configuration/updater/ChangeAttributesTask.java4
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/configuration/updater/ChangeStateTask.java2
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/configuration/updater/CreateChildTask.java2
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/configuration/updater/SetAttributeTask.java2
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/configuration/updater/TaskExecutor.java76
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/connection/IConnectionRegistry.java4
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/consumer/Consumer.java8
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/consumer/ConsumerTarget.java5
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/exchange/AMQUnknownExchangeType.java (renamed from java/common/src/main/java/org/apache/qpid/AMQUnknownExchangeType.java)8
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java40
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchange.java33
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeFactory.java13
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeRegistry.java50
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchange.java2
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchangeType.java3
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/exchange/Exchange.java23
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeFactory.java11
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeInUseException.java45
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeInitialiser.java31
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeRegistry.java10
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchange.java2
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchangeType.java2
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersBinding.java2
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchangeType.java3
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchange.java6
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchangeType.java3
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/filter/AMQInvalidArgumentException.java43
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/filter/FilterManagerFactory.java4
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/filter/FilterSupport.java1
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/filter/NoConsumerFilter.java48
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/message/AbstractServerMessageImpl.java5
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/message/MessageInstance.java6
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/message/MessageSource.java18
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/message/internal/InternalMessage.java10
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/message/internal/InternalMessageMetaData.java3
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/message/internal/InternalMessageMetaDataType.java5
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractAdapter.java2
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AmqpPortAdapter.java3
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AuthenticationProviderAdapter.java5
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BindingAdapter.java9
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java10
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ExchangeAdapter.java17
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProvider.java4
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/KeyStoreAdapter.java3
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/QueueAdapter.java18
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java38
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/plugin/ExchangeType.java3
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/plugin/QpidServiceLoader.java3
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/plugin/VirtualHostFactory.java2
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/protocol/AMQConnectionModel.java7
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/protocol/AMQSessionModel.java7
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueue.java11
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java44
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/queue/BaseQueue.java3
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumer.java26
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueEntryImpl.java5
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueFactory.java7
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueRunner.java14
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java67
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/queue/SortedQueue.java3
-rwxr-xr-xjava/broker-core/src/main/java/org/apache/qpid/server/queue/SubFlushRunner.java5
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/security/QpidSecurityException.java43
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/security/auth/database/HashedUser.java5
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManager.java21
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ldap/LDAPSSLSocketFactoryGenerator.java17
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HashedSaslServer.java4
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HexSaslServer.java4
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/security/group/FileGroupDatabase.java3
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractJDBCMessageStore.java202
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractMemoryMessageStore.java20
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationRecoverer.java18
-rwxr-xr-xjava/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStore.java22
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStoreHelper.java17
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java119
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/store/MessageStore.java6
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/store/NullMessageStore.java16
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/store/StoreException.java (renamed from java/broker-core/src/main/java/org/apache/qpid/server/store/MessageStoreClosedException.java)25
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/store/Transaction.java22
-rwxr-xr-xjava/broker-core/src/main/java/org/apache/qpid/server/txn/AsyncAutoCommitTransaction.java41
-rwxr-xr-xjava/broker-core/src/main/java/org/apache/qpid/server/txn/AutoCommitTransaction.java41
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/txn/DtxBranch.java32
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/txn/DtxRegistry.java8
-rwxr-xr-xjava/broker-core/src/main/java/org/apache/qpid/server/txn/LocalTransaction.java66
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/util/ConnectionScopedRuntimeException.java (renamed from java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/state/IllegalStateTransitionException.java)32
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/util/MapJsonSerializer.java4
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/util/ServerScopedRuntimeException.java48
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java73
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/BindingRecoverer.java9
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ExchangeExistsException.java3
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ExchangeIsAlternateException.java7
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ExchangeRecoverer.java17
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/QueueExistsException.java (renamed from java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/plugins/QueueExistsException.java)5
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/QueueRecoverer.java9
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/RequiredExchangeException.java7
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ReservedExchangeNameException.java4
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/StandardVirtualHost.java39
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/StandardVirtualHostFactory.java2
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/UnknownExchangeException.java7
-rwxr-xr-xjava/broker-core/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java17
-rwxr-xr-xjava/broker-core/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostConfigRecoveryHandler.java127
-rw-r--r--java/broker-core/src/test/java/org/apache/qpid/server/configuration/updater/TaskExecutorTest.java64
-rw-r--r--java/broker-core/src/test/java/org/apache/qpid/server/consumer/MockConsumer.java14
-rw-r--r--java/broker-core/src/test/java/org/apache/qpid/server/exchange/DefaultExchangeFactoryTest.java3
-rw-r--r--java/broker-core/src/test/java/org/apache/qpid/server/exchange/FanoutExchangeTest.java14
-rw-r--r--java/broker-core/src/test/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java5
-rw-r--r--java/broker-core/src/test/java/org/apache/qpid/server/exchange/TopicExchangeTest.java26
-rw-r--r--java/broker-core/src/test/java/org/apache/qpid/server/logging/actors/AMQPConnectionActorTest.java3
-rw-r--r--java/broker-core/src/test/java/org/apache/qpid/server/logging/actors/CurrentActorTest.java4
-rw-r--r--java/broker-core/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java16
-rw-r--r--java/broker-core/src/test/java/org/apache/qpid/server/queue/MockAMQQueue.java20
-rw-r--r--java/broker-core/src/test/java/org/apache/qpid/server/queue/MockMessageInstance.java5
-rw-r--r--java/broker-core/src/test/java/org/apache/qpid/server/queue/PriorityQueueTest.java10
-rw-r--r--java/broker-core/src/test/java/org/apache/qpid/server/queue/QueueEntryImplTestBase.java3
-rw-r--r--java/broker-core/src/test/java/org/apache/qpid/server/queue/QueueEntryListTestBase.java9
-rw-r--r--java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueTestBase.java62
-rw-r--r--java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleQueueEntryImplTest.java6
-rw-r--r--java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryListTest.java5
-rw-r--r--java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryTest.java3
-rw-r--r--java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueEntryListTest.java3
-rw-r--r--java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueTest.java63
-rw-r--r--java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java5
-rw-r--r--java/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java15
-rw-r--r--java/broker-core/src/test/java/org/apache/qpid/server/store/TestableMemoryMessageStore.java11
-rw-r--r--java/broker-core/src/test/java/org/apache/qpid/server/txn/MockStoreTransaction.java16
-rw-r--r--java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java9
-rw-r--r--java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java4
-rw-r--r--java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java9
-rw-r--r--java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/StandardVirtualHostTest.java13
-rw-r--r--java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ConsumerTarget_0_10.java10
-rw-r--r--java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageConverter_v0_10.java4
-rw-r--r--java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageConverter_v0_10_to_Internal.java5
-rw-r--r--java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerConnection.java32
-rw-r--r--java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSession.java13
-rw-r--r--java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegate.java91
-rw-r--r--java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java108
-rw-r--r--java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngine.java140
-rw-r--r--java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolSession.java4
-rw-r--r--java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/ClientDeliveryMethod.java2
-rw-r--r--java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/ConsumerTarget_0_8.java9
-rw-r--r--java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/MessageConverter_Internal_to_v0_8.java3
-rw-r--r--java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/MessageConverter_v0_8_to_Internal.java5
-rw-r--r--java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/MessageMetaData.java19
-rw-r--r--java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicConsumeMethodHandler.java11
-rw-r--r--java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicGetMethodHandler.java36
-rw-r--r--java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicPublishMethodHandler.java10
-rw-r--r--java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ChannelOpenHandler.java5
-rw-r--r--java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeclareHandler.java13
-rw-r--r--java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeleteHandler.java11
-rw-r--r--java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueBindHandler.java5
-rw-r--r--java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueDeclareHandler.java27
-rw-r--r--java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueDeleteHandler.java11
-rw-r--r--java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueuePurgeHandler.java13
-rw-r--r--java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueUnbindHandler.java10
-rw-r--r--java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/output/ProtocolOutputConverter.java8
-rw-r--r--java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/output/ProtocolOutputConverterImpl.java10
-rw-r--r--java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/state/AMQStateManager.java39
-rw-r--r--java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AMQChannelTest.java2
-rw-r--r--java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AckTest.java46
-rw-r--r--java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AcknowledgeTest.java14
-rw-r--r--java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/BrokerTestHelper_0_8.java4
-rw-r--r--java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/InternalTestProtocolSession.java10
-rw-r--r--java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/QueueBrowserUsesNoAckTest.java4
-rw-r--r--java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Connection_1_0.java5
-rw-r--r--java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/ConsumerTarget_1_0.java8
-rw-r--r--java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/ExchangeDestination.java4
-rw-r--r--java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_Internal_to_v1_0.java3
-rw-r--r--java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_to_1_0.java5
-rw-r--r--java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_v1_0_to_Internal.java9
-rwxr-xr-xjava/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageMetaData_1_0.java3
-rw-r--r--java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/ProtocolEngine_1_0_0_SASL.java263
-rw-r--r--java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/QueueDestination.java39
-rw-r--r--java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java57
-rw-r--r--java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java24
-rw-r--r--java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java11
-rw-r--r--java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStore.java12
-rw-r--r--java/broker-plugins/management-amqp/src/main/java/org/apache/qpid/server/management/amqp/ManagementNode.java15
-rw-r--r--java/broker-plugins/management-amqp/src/main/java/org/apache/qpid/server/management/amqp/ManagementNodeConsumer.java13
-rw-r--r--java/broker-plugins/management-amqp/src/main/java/org/apache/qpid/server/management/amqp/ManagementResponse.java5
-rw-r--r--java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java7
-rw-r--r--java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementUtil.java3
-rw-r--r--java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/AbstractServlet.java14
-rw-r--r--java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java4
-rw-r--r--java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/SaslServlet.java3
-rw-r--r--java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagedObjectRegistry.java3
-rw-r--r--java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagement.java3
-rw-r--r--java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ConnectionMBean.java3
-rw-r--r--java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ExchangeMBean.java3
-rw-r--r--java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/LoggingManagementMBean.java3
-rw-r--r--java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/QueueMBean.java3
-rw-r--r--java/broker-plugins/websocket/src/main/java/org/apache/qpid/server/transport/websocket/WebSocketProvider.java7
-rw-r--r--java/common/src/main/java/org/apache/qpid/AMQStoreException.java46
-rw-r--r--java/systests/src/main/java/org/apache/qpid/server/store/MessageStoreTest.java33
-rw-r--r--java/systests/src/main/java/org/apache/qpid/server/store/QuotaMessageStore.java18
-rw-r--r--java/systests/src/main/java/org/apache/qpid/server/store/SlowMessageStore.java65
217 files changed, 2081 insertions, 2309 deletions
diff --git a/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ConnectionEndpoint.java b/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ConnectionEndpoint.java
index 9c93c1f0a5..270abef88b 100644
--- a/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ConnectionEndpoint.java
+++ b/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ConnectionEndpoint.java
@@ -369,7 +369,7 @@ public class ConnectionEndpoint implements DescribedTypeConstructorRegistry.Sour
Error error = new Error();
error.setCondition(ConnectionError.CONNECTION_FORCED);
error.setDescription("Connection close sent before connection was opened");
- connectionError(error);
+ close(error);
break;
case OPEN:
_state = ConnectionState.CLOSE_RECEIVED;
@@ -386,7 +386,7 @@ public class ConnectionEndpoint implements DescribedTypeConstructorRegistry.Sour
notifyAll();
}
- protected synchronized void connectionError(Error error)
+ public synchronized void close(Error error)
{
Close close = new Close();
close.setError(error);
@@ -476,7 +476,7 @@ public class ConnectionEndpoint implements DescribedTypeConstructorRegistry.Sour
error.setDescription("BEGIN received on channel " + channel + " with given remote-channel "
+ begin.getRemoteChannel() + " which is outside the valid range of 0 to "
+ _channelMax + ".");
- connectionError(error);
+ close(error);
return;
}
if (endpoint != null)
@@ -498,7 +498,7 @@ public class ConnectionEndpoint implements DescribedTypeConstructorRegistry.Sour
final Error error = new Error();
error.setCondition(ConnectionError.FRAMING_ERROR);
error.setDescription("BEGIN received on channel " + channel + " which is already in use.");
- connectionError(error);
+ close(error);
}
}
else
@@ -507,7 +507,7 @@ public class ConnectionEndpoint implements DescribedTypeConstructorRegistry.Sour
error.setCondition(ConnectionError.FRAMING_ERROR);
error.setDescription("BEGIN received on channel " + channel + " with given remote-channel "
+ begin.getRemoteChannel() + " which is not known as a begun session.");
- connectionError(error);
+ close(error);
}
@@ -547,7 +547,7 @@ public class ConnectionEndpoint implements DescribedTypeConstructorRegistry.Sour
final Error error = new Error();
error.setCondition(ConnectionError.FRAMING_ERROR);
error.setDescription("BEGIN received on channel " + channel + " which is already in use.");
- connectionError(error);
+ close(error);
}
}
diff --git a/java/bdbstore/jmx/src/main/java/org/apache/qpid/server/store/berkeleydb/jmx/BDBHAMessageStoreManagerMBean.java b/java/bdbstore/jmx/src/main/java/org/apache/qpid/server/store/berkeleydb/jmx/BDBHAMessageStoreManagerMBean.java
index 28528ec83c..aa4ddd8181 100644
--- a/java/bdbstore/jmx/src/main/java/org/apache/qpid/server/store/berkeleydb/jmx/BDBHAMessageStoreManagerMBean.java
+++ b/java/bdbstore/jmx/src/main/java/org/apache/qpid/server/store/berkeleydb/jmx/BDBHAMessageStoreManagerMBean.java
@@ -36,7 +36,7 @@ import javax.management.openmbean.TabularDataSupport;
import javax.management.openmbean.TabularType;
import org.apache.log4j.Logger;
-import org.apache.qpid.AMQStoreException;
+import org.apache.qpid.server.store.StoreException;
import org.apache.qpid.server.jmx.AMQManagedObject;
import org.apache.qpid.server.jmx.ManagedObject;
import org.apache.qpid.server.store.berkeleydb.BDBHAMessageStore;
@@ -189,7 +189,7 @@ public class BDBHAMessageStoreManagerMBean extends AMQManagedObject implements M
{
_store.removeNodeFromGroup(nodeName);
}
- catch (AMQStoreException e)
+ catch (StoreException e)
{
LOGGER.error("Failed to remove node " + nodeName + " from group", e);
throw new JMException(e.getMessage());
@@ -203,7 +203,7 @@ public class BDBHAMessageStoreManagerMBean extends AMQManagedObject implements M
{
_store.setDesignatedPrimary(primary);
}
- catch (AMQStoreException e)
+ catch (StoreException e)
{
LOGGER.error("Failed to set node " + _store.getNodeName() + " as designated primary", e);
throw new JMException(e.getMessage());
@@ -217,7 +217,7 @@ public class BDBHAMessageStoreManagerMBean extends AMQManagedObject implements M
{
_store.updateAddress(nodeName, newHostName, newPort);
}
- catch(AMQStoreException e)
+ catch(StoreException e)
{
LOGGER.error("Failed to update address for node " + nodeName + " to " + newHostName + ":" + newPort, e);
throw new JMException(e.getMessage());
diff --git a/java/bdbstore/jmx/src/test/java/org/apache/qpid/server/store/berkeleydb/jmx/BDBHAMessageStoreManagerMBeanTest.java b/java/bdbstore/jmx/src/test/java/org/apache/qpid/server/store/berkeleydb/jmx/BDBHAMessageStoreManagerMBeanTest.java
index 298d5bc045..54051ab630 100644
--- a/java/bdbstore/jmx/src/test/java/org/apache/qpid/server/store/berkeleydb/jmx/BDBHAMessageStoreManagerMBeanTest.java
+++ b/java/bdbstore/jmx/src/test/java/org/apache/qpid/server/store/berkeleydb/jmx/BDBHAMessageStoreManagerMBeanTest.java
@@ -37,15 +37,13 @@ import javax.management.openmbean.TabularData;
import junit.framework.TestCase;
-import org.apache.qpid.AMQStoreException;
+import org.apache.qpid.server.store.StoreException;
import org.apache.qpid.server.jmx.AMQManagedObject;
import org.apache.qpid.server.jmx.ManagedObjectRegistry;
import org.apache.qpid.server.logging.SystemOutMessageLogger;
import org.apache.qpid.server.logging.actors.CurrentActor;
import org.apache.qpid.server.logging.actors.TestLogActor;
import org.apache.qpid.server.store.berkeleydb.BDBHAMessageStore;
-import org.apache.qpid.server.store.berkeleydb.jmx.BDBHAMessageStoreManagerMBean;
-import org.apache.qpid.server.store.berkeleydb.jmx.ManagedBDBHAMessageStore;
public class BDBHAMessageStoreManagerMBeanTest extends TestCase
{
@@ -170,7 +168,7 @@ public class BDBHAMessageStoreManagerMBeanTest extends TestCase
public void testRemoveNodeFromReplicationGroupWithError() throws Exception
{
- doThrow(new AMQStoreException("mocked exception")).when(_store).removeNodeFromGroup(TEST_NODE_NAME);
+ doThrow(new StoreException("mocked exception")).when(_store).removeNodeFromGroup(TEST_NODE_NAME);
try
{
@@ -192,7 +190,7 @@ public class BDBHAMessageStoreManagerMBeanTest extends TestCase
public void testSetAsDesignatedPrimaryWithError() throws Exception
{
- doThrow(new AMQStoreException("mocked exception")).when(_store).setDesignatedPrimary(true);
+ doThrow(new StoreException("mocked exception")).when(_store).setDesignatedPrimary(true);
try
{
diff --git a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java b/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java
index 35efa55569..37fb77f547 100644
--- a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java
+++ b/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java
@@ -44,7 +44,7 @@ import java.util.concurrent.atomic.AtomicLong;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.log4j.Logger;
-import org.apache.qpid.AMQStoreException;
+import org.apache.qpid.server.store.StoreException;
import org.apache.qpid.server.message.EnqueueableMessage;
import org.apache.qpid.server.model.VirtualHost;
import org.apache.qpid.server.queue.AMQQueue;
@@ -157,7 +157,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
_eventManager.addEventListener(eventListener, events);
}
- public void configureConfigStore(VirtualHost virtualHost, ConfigurationRecoveryHandler recoveryHandler) throws Exception
+ public void configureConfigStore(VirtualHost virtualHost, ConfigurationRecoveryHandler recoveryHandler)
{
_stateManager.attainState(State.INITIALISING);
@@ -166,7 +166,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
}
public void configureMessageStore(VirtualHost virtualHost, MessageStoreRecoveryHandler messageRecoveryHandler,
- TransactionLogRecoveryHandler tlogRecoveryHandler) throws Exception
+ TransactionLogRecoveryHandler tlogRecoveryHandler)
{
if(_stateManager.isInState(State.INITIAL))
{
@@ -181,14 +181,14 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
completeInitialisation();
}
- private void completeInitialisation() throws Exception
+ private void completeInitialisation()
{
configure(_virtualHost);
_stateManager.attainState(State.INITIALISED);
}
- public synchronized void activate() throws Exception
+ public synchronized void activate()
{
// check if acting as a durable config store, but not a message store
if(_stateManager.isInState(State.INITIALISING))
@@ -228,12 +228,12 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
*
* @throws Exception If any error occurs that means the store is unable to configure itself.
*/
- public void configure(VirtualHost virtualHost) throws Exception
+ public void configure(VirtualHost virtualHost)
{
configure(virtualHost, _messageRecoveryHandler != null);
}
- public void configure(VirtualHost virtualHost, boolean isMessageStore) throws Exception
+ public void configure(VirtualHost virtualHost, boolean isMessageStore)
{
String name = virtualHost.getName();
final String defaultPath = System.getProperty("QPID_WORK") + File.separator + "bdbstore" + File.separator + name;
@@ -327,9 +327,9 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
*
* This is required if you do not want to perform recovery of the store data
*
- * @throws AMQStoreException if the store is not in the correct state
+ * @throws org.apache.qpid.server.store.StoreException if the store is not in the correct state
*/
- void startWithNoRecover() throws AMQStoreException
+ void startWithNoRecover() throws StoreException
{
_stateManager.attainState(State.INITIALISING);
_stateManager.attainState(State.INITIALISED);
@@ -337,7 +337,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
_stateManager.attainState(State.ACTIVE);
}
- protected void setupStore(File storePath, String name) throws DatabaseException, AMQStoreException
+ protected void setupStore(File storePath, String name)
{
_environment = createEnvironment(storePath);
@@ -387,7 +387,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
*
* @throws Exception If the close fails.
*/
- public void close() throws Exception
+ public void close()
{
if (_closed.compareAndSet(false, true))
{
@@ -397,7 +397,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
}
}
- protected void closeInternal() throws Exception
+ protected void closeInternal()
{
if (_messageMetaDataDb != null)
{
@@ -472,7 +472,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
}
- private void recoverConfig(ConfigurationRecoveryHandler recoveryHandler) throws AMQStoreException
+ private void recoverConfig(ConfigurationRecoveryHandler recoveryHandler)
{
try
{
@@ -488,12 +488,12 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
}
catch (DatabaseException e)
{
- throw new AMQStoreException("Error recovering persistent state: " + e.getMessage(), e);
+ throw new StoreException("Error recovering persistent state: " + e.getMessage(), e);
}
}
- private void updateConfigVersion(int newConfigVersion) throws AMQStoreException
+ private void updateConfigVersion(int newConfigVersion) throws StoreException
{
Cursor cursor = null;
try
@@ -510,7 +510,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
OperationStatus status = cursor.put(key, value);
if (status != OperationStatus.SUCCESS)
{
- throw new AMQStoreException("Error setting config version: " + status);
+ throw new StoreException("Error setting config version: " + status);
}
}
cursor.close();
@@ -524,7 +524,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
}
- private int getConfigVersion() throws AMQStoreException
+ private int getConfigVersion() throws StoreException
{
Cursor cursor = null;
try
@@ -543,7 +543,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
OperationStatus status = _configVersionDb.put(null, key, value);
if (status != OperationStatus.SUCCESS)
{
- throw new AMQStoreException("Error initialising config version: " + status);
+ throw new StoreException("Error initialising config version: " + status);
}
return 0;
}
@@ -706,7 +706,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
dtxrh.completeDtxRecordRecovery();
}
- public void removeMessage(long messageId, boolean sync) throws AMQStoreException
+ public void removeMessage(long messageId, boolean sync) throws StoreException
{
boolean complete = false;
@@ -818,11 +818,11 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
}
catch (DatabaseException e1)
{
- throw new AMQStoreException("Error aborting transaction " + e1, e1);
+ throw new StoreException("Error aborting transaction " + e1, e1);
}
}
- throw new AMQStoreException("Error removing message with id " + messageId + " from database: " + e.getMessage(), e);
+ throw new StoreException("Error removing message with id " + messageId + " from database: " + e.getMessage(), e);
}
finally
{
@@ -835,14 +835,14 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
}
catch (DatabaseException e1)
{
- throw new AMQStoreException("Error aborting transaction " + e1, e1);
+ throw new StoreException("Error aborting transaction " + e1, e1);
}
}
}
}
@Override
- public void create(UUID id, String type, Map<String, Object> attributes) throws AMQStoreException
+ public void create(UUID id, String type, Map<String, Object> attributes) throws StoreException
{
if (_stateManager.isInState(State.ACTIVE))
{
@@ -852,7 +852,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
}
@Override
- public void remove(UUID id, String type) throws AMQStoreException
+ public void remove(UUID id, String type) throws StoreException
{
if (LOGGER.isDebugEnabled())
{
@@ -861,12 +861,12 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
OperationStatus status = removeConfiguredObject(null, id);
if (status == OperationStatus.NOTFOUND)
{
- throw new AMQStoreException("Configured object of type " + type + " with id " + id + " not found");
+ throw new StoreException("Configured object of type " + type + " with id " + id + " not found");
}
}
@Override
- public UUID[] removeConfiguredObjects(final UUID... objects) throws AMQStoreException
+ public UUID[] removeConfiguredObjects(final UUID... objects) throws StoreException
{
com.sleepycat.je.Transaction txn = _environment.beginTransaction(null, null);
Collection<UUID> removed = new ArrayList<UUID>(objects.length);
@@ -883,17 +883,17 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
}
@Override
- public void update(UUID id, String type, Map<String, Object> attributes) throws AMQStoreException
+ public void update(UUID id, String type, Map<String, Object> attributes) throws StoreException
{
update(false, id, type, attributes, null);
}
- public void update(ConfiguredObjectRecord... records) throws AMQStoreException
+ public void update(ConfiguredObjectRecord... records) throws StoreException
{
update(false, records);
}
- public void update(boolean createIfNecessary, ConfiguredObjectRecord... records) throws AMQStoreException
+ public void update(boolean createIfNecessary, ConfiguredObjectRecord... records) throws StoreException
{
com.sleepycat.je.Transaction txn = _environment.beginTransaction(null, null);
for(ConfiguredObjectRecord record : records)
@@ -903,7 +903,8 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
txn.commit();
}
- private void update(boolean createIfNecessary, UUID id, String type, Map<String, Object> attributes, com.sleepycat.je.Transaction txn) throws AMQStoreException
+ private void update(boolean createIfNecessary, UUID id, String type, Map<String, Object> attributes, com.sleepycat.je.Transaction txn) throws
+ StoreException
{
if (LOGGER.isDebugEnabled())
{
@@ -930,17 +931,17 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
status = _configuredObjectsDb.put(txn, key, newValue);
if (status != OperationStatus.SUCCESS)
{
- throw new AMQStoreException("Error updating queue details within the store: " + status);
+ throw new StoreException("Error updating queue details within the store: " + status);
}
}
else if (status != OperationStatus.NOTFOUND)
{
- throw new AMQStoreException("Error finding queue details within the store: " + status);
+ throw new StoreException("Error finding queue details within the store: " + status);
}
}
catch (DatabaseException e)
{
- throw new AMQStoreException("Error updating queue details within the store: " + e,e);
+ throw new StoreException("Error updating queue details within the store: " + e,e);
}
}
@@ -951,10 +952,10 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
* @param queue The the queue to place the message on.
* @param messageId The message to enqueue.
*
- * @throws AMQStoreException If the operation fails for any reason.
+ * @throws org.apache.qpid.server.store.StoreException If the operation fails for any reason.
*/
public void enqueueMessage(final com.sleepycat.je.Transaction tx, final TransactionLogResource queue,
- long messageId) throws AMQStoreException
+ long messageId) throws StoreException
{
DatabaseEntry key = new DatabaseEntry();
@@ -977,7 +978,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
catch (DatabaseException e)
{
LOGGER.error("Failed to enqueue: " + e.getMessage(), e);
- throw new AMQStoreException("Error writing enqueued message with id " + messageId + " for queue "
+ throw new StoreException("Error writing enqueued message with id " + messageId + " for queue "
+ (queue instanceof AMQQueue ? ((AMQQueue) queue).getName() + " with id " : "") + queue.getId()
+ " to database", e);
}
@@ -990,10 +991,10 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
* @param queue The queue to take the message from.
* @param messageId The message to dequeue.
*
- * @throws AMQStoreException If the operation fails for any reason, or if the specified message does not exist.
+ * @throws org.apache.qpid.server.store.StoreException If the operation fails for any reason, or if the specified message does not exist.
*/
public void dequeueMessage(final com.sleepycat.je.Transaction tx, final TransactionLogResource queue,
- long messageId) throws AMQStoreException
+ long messageId) throws StoreException
{
DatabaseEntry key = new DatabaseEntry();
@@ -1013,12 +1014,12 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
OperationStatus status = _deliveryDb.delete(tx, key);
if (status == OperationStatus.NOTFOUND)
{
- throw new AMQStoreException("Unable to find message with id " + messageId + " on queue "
+ throw new StoreException("Unable to find message with id " + messageId + " on queue "
+ (queue instanceof AMQQueue ? ((AMQQueue) queue).getName() + " with id " : "") + id);
}
else if (status != OperationStatus.SUCCESS)
{
- throw new AMQStoreException("Unable to remove message with id " + messageId + " on queue"
+ throw new StoreException("Unable to remove message with id " + messageId + " on queue"
+ (queue instanceof AMQQueue ? ((AMQQueue) queue).getName() + " with id " : "") + id);
}
@@ -1036,7 +1037,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
LOGGER.error("Failed to dequeue message " + messageId + ": " + e.getMessage(), e);
LOGGER.error(tx);
- throw new AMQStoreException("Error accessing database while dequeuing message: " + e.getMessage(), e);
+ throw new StoreException("Error accessing database while dequeuing message: " + e.getMessage(), e);
}
}
@@ -1046,7 +1047,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
byte[] globalId,
byte[] branchId,
org.apache.qpid.server.store.Transaction.Record[] enqueues,
- org.apache.qpid.server.store.Transaction.Record[] dequeues) throws AMQStoreException
+ org.apache.qpid.server.store.Transaction.Record[] dequeues) throws StoreException
{
DatabaseEntry key = new DatabaseEntry();
Xid xid = new Xid(format, globalId, branchId);
@@ -1065,12 +1066,12 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
catch (DatabaseException e)
{
LOGGER.error("Failed to write xid: " + e.getMessage(), e);
- throw new AMQStoreException("Error writing xid to database", e);
+ throw new StoreException("Error writing xid to database", e);
}
}
private void removeXid(com.sleepycat.je.Transaction txn, long format, byte[] globalId, byte[] branchId)
- throws AMQStoreException
+ throws StoreException
{
DatabaseEntry key = new DatabaseEntry();
Xid xid = new Xid(format, globalId, branchId);
@@ -1085,11 +1086,11 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
OperationStatus status = _xidDb.delete(txn, key);
if (status == OperationStatus.NOTFOUND)
{
- throw new AMQStoreException("Unable to find xid");
+ throw new StoreException("Unable to find xid");
}
else if (status != OperationStatus.SUCCESS)
{
- throw new AMQStoreException("Unable to remove xid");
+ throw new StoreException("Unable to remove xid");
}
}
@@ -1099,7 +1100,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
LOGGER.error("Failed to remove xid ", e);
LOGGER.error(txn);
- throw new AMQStoreException("Error accessing database while removing xid: " + e.getMessage(), e);
+ throw new StoreException("Error accessing database while removing xid: " + e.getMessage(), e);
}
}
@@ -1108,13 +1109,14 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
*
* @param tx The transaction to commit all operations for.
*
- * @throws AMQStoreException If the operation fails for any reason.
+ * @throws org.apache.qpid.server.store.StoreException If the operation fails for any reason.
*/
- private StoreFuture commitTranImpl(final com.sleepycat.je.Transaction tx, boolean syncCommit) throws AMQStoreException
+ private StoreFuture commitTranImpl(final com.sleepycat.je.Transaction tx, boolean syncCommit) throws
+ StoreException
{
if (tx == null)
{
- throw new AMQStoreException("Fatal internal error: transactional is null at commitTran");
+ throw new StoreException("Fatal internal error: transactional is null at commitTran");
}
StoreFuture result;
@@ -1130,7 +1132,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
}
catch (DatabaseException e)
{
- throw new AMQStoreException("Error commit tx: " + e.getMessage(), e);
+ throw new StoreException("Error commit tx: " + e.getMessage(), e);
}
return result;
@@ -1141,9 +1143,9 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
*
* @param tx The transaction to abandon.
*
- * @throws AMQStoreException If the operation fails for any reason.
+ * @throws org.apache.qpid.server.store.StoreException If the operation fails for any reason.
*/
- public void abortTran(final com.sleepycat.je.Transaction tx) throws AMQStoreException
+ public void abortTran(final com.sleepycat.je.Transaction tx) throws StoreException
{
if (LOGGER.isDebugEnabled())
{
@@ -1156,7 +1158,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
}
catch (DatabaseException e)
{
- throw new AMQStoreException("Error aborting transaction: " + e.getMessage(), e);
+ throw new StoreException("Error aborting transaction: " + e.getMessage(), e);
}
}
@@ -1167,7 +1169,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
*
* @return a list of message ids for messages enqueued for a particular queue
*/
- List<Long> getEnqueuedMessages(UUID queueId) throws AMQStoreException
+ List<Long> getEnqueuedMessages(UUID queueId) throws StoreException
{
Cursor cursor = null;
try
@@ -1203,7 +1205,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
}
catch (DatabaseException e)
{
- throw new AMQStoreException("Database error: " + e.getMessage(), e);
+ throw new StoreException("Database error: " + e.getMessage(), e);
}
finally
{
@@ -1215,7 +1217,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
}
catch (DatabaseException e)
{
- throw new AMQStoreException("Error closing cursor: " + e.getMessage(), e);
+ throw new StoreException("Error closing cursor: " + e.getMessage(), e);
}
}
}
@@ -1239,10 +1241,10 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
* @param offset The offset of the data chunk in the message.
* @param contentBody The content of the data chunk.
*
- * @throws AMQStoreException If the operation fails for any reason, or if the specified message does not exist.
+ * @throws org.apache.qpid.server.store.StoreException If the operation fails for any reason, or if the specified message does not exist.
*/
protected void addContent(final com.sleepycat.je.Transaction tx, long messageId, int offset,
- ByteBuffer contentBody) throws AMQStoreException
+ ByteBuffer contentBody) throws StoreException
{
DatabaseEntry key = new DatabaseEntry();
LongBinding.longToEntry(messageId, key);
@@ -1254,7 +1256,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
OperationStatus status = _messageContentDb.put(tx, key, value);
if (status != OperationStatus.SUCCESS)
{
- throw new AMQStoreException("Error adding content for message id " + messageId + ": " + status);
+ throw new StoreException("Error adding content for message id " + messageId + ": " + status);
}
if (LOGGER.isDebugEnabled())
@@ -1265,7 +1267,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
}
catch (DatabaseException e)
{
- throw new AMQStoreException("Error writing AMQMessage with id " + messageId + " to database: " + e.getMessage(), e);
+ throw new StoreException("Error writing AMQMessage with id " + messageId + " to database: " + e.getMessage(), e);
}
}
@@ -1276,11 +1278,11 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
* @param messageId The message to store the data for.
* @param messageMetaData The message meta data to store.
*
- * @throws AMQStoreException If the operation fails for any reason, or if the specified message does not exist.
+ * @throws org.apache.qpid.server.store.StoreException If the operation fails for any reason, or if the specified message does not exist.
*/
private void storeMetaData(final com.sleepycat.je.Transaction tx, long messageId,
StorableMessageMetaData messageMetaData)
- throws AMQStoreException
+ throws StoreException
{
if (LOGGER.isDebugEnabled())
{
@@ -1305,7 +1307,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
}
catch (DatabaseException e)
{
- throw new AMQStoreException("Error writing message metadata with id " + messageId + " to database: " + e.getMessage(), e);
+ throw new StoreException("Error writing message metadata with id " + messageId + " to database: " + e.getMessage(), e);
}
}
@@ -1316,9 +1318,9 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
*
* @return The message meta data.
*
- * @throws AMQStoreException If the operation fails for any reason, or if the specified message does not exist.
+ * @throws org.apache.qpid.server.store.StoreException If the operation fails for any reason, or if the specified message does not exist.
*/
- public StorableMessageMetaData getMessageMetaData(long messageId) throws AMQStoreException
+ public StorableMessageMetaData getMessageMetaData(long messageId) throws StoreException
{
if (LOGGER.isDebugEnabled())
{
@@ -1336,7 +1338,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
OperationStatus status = _messageMetaDataDb.get(null, key, value, LockMode.READ_UNCOMMITTED);
if (status != OperationStatus.SUCCESS)
{
- throw new AMQStoreException("Metadata not found for message with id " + messageId);
+ throw new StoreException("Metadata not found for message with id " + messageId);
}
StorableMessageMetaData mdd = messageBinding.entryToObject(value);
@@ -1345,7 +1347,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
}
catch (DatabaseException e)
{
- throw new AMQStoreException("Error reading message metadata for message with id " + messageId + ": " + e.getMessage(), e);
+ throw new StoreException("Error reading message metadata for message with id " + messageId + ": " + e.getMessage(), e);
}
}
@@ -1359,9 +1361,9 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
*
* @return The number of bytes inserted into the destination
*
- * @throws AMQStoreException If the operation fails for any reason, or if the specified message does not exist.
+ * @throws org.apache.qpid.server.store.StoreException If the operation fails for any reason, or if the specified message does not exist.
*/
- public int getContent(long messageId, int offset, ByteBuffer dst) throws AMQStoreException
+ public int getContent(long messageId, int offset, ByteBuffer dst) throws StoreException
{
DatabaseEntry contentKeyEntry = new DatabaseEntry();
LongBinding.longToEntry(messageId, contentKeyEntry);
@@ -1385,7 +1387,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
int size = dataAsBytes.length;
if (offset > size)
{
- throw new RuntimeException("Offset " + offset + " is greater than message size " + size
+ throw new StoreException("Offset " + offset + " is greater than message size " + size
+ " for message id " + messageId + "!");
}
@@ -1402,7 +1404,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
}
catch (DatabaseException e)
{
- throw new AMQStoreException("Error getting AMQMessage with id " + messageId + " to database: " + e.getMessage(), e);
+ throw new StoreException("Error getting AMQMessage with id " + messageId + " to database: " + e.getMessage(), e);
}
}
@@ -1445,9 +1447,9 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
* Makes the specified configured object persistent.
*
* @param configuredObject Details of the configured object to store.
- * @throws AMQStoreException If the operation fails for any reason.
+ * @throws org.apache.qpid.server.store.StoreException If the operation fails for any reason.
*/
- private void storeConfiguredObjectEntry(ConfiguredObjectRecord configuredObject) throws AMQStoreException
+ private void storeConfiguredObjectEntry(ConfiguredObjectRecord configuredObject) throws StoreException
{
if (_stateManager.isInState(State.ACTIVE))
{
@@ -1465,19 +1467,19 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
OperationStatus status = _configuredObjectsDb.put(null, key, value);
if (status != OperationStatus.SUCCESS)
{
- throw new AMQStoreException("Error writing configured object " + configuredObject + " to database: "
+ throw new StoreException("Error writing configured object " + configuredObject + " to database: "
+ status);
}
}
catch (DatabaseException e)
{
- throw new AMQStoreException("Error writing configured object " + configuredObject
+ throw new StoreException("Error writing configured object " + configuredObject
+ " to database: " + e.getMessage(), e);
}
}
}
- private OperationStatus removeConfiguredObject(Transaction tx, UUID id) throws AMQStoreException
+ private OperationStatus removeConfiguredObject(Transaction tx, UUID id) throws StoreException
{
LOGGER.debug("Removing configured object: " + id);
@@ -1490,7 +1492,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
}
catch (DatabaseException e)
{
- throw new AMQStoreException("Error deleting of configured object with id " + id + " from database", e);
+ throw new StoreException("Error deleting of configured object with id " + id + " from database", e);
}
}
@@ -1531,14 +1533,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
StorableMessageMetaData metaData = _metaDataRef.get();
if(metaData == null)
{
- try
- {
- metaData = AbstractBDBMessageStore.this.getMessageMetaData(_messageId);
- }
- catch (AMQStoreException e)
- {
- throw new RuntimeException(e);
- }
+ metaData = AbstractBDBMessageStore.this.getMessageMetaData(_messageId);
_metaDataRef = new SoftReference<StorableMessageMetaData>(metaData);
}
@@ -1583,15 +1578,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
}
else
{
- try
- {
- return AbstractBDBMessageStore.this.getContent(_messageId, offsetInMessage, dst);
- }
- catch (AMQStoreException e)
- {
- // TODO maybe should throw a checked exception, or at least log before throwing
- throw new RuntimeException(e);
- }
+ return AbstractBDBMessageStore.this.getContent(_messageId, offsetInMessage, dst);
}
}
@@ -1625,16 +1612,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
}
catch(DatabaseException e)
{
- throw new RuntimeException(e);
- }
- catch (AMQStoreException e)
- {
- throw new RuntimeException(e);
- }
- catch (RuntimeException e)
- {
- LOGGER.error("RuntimeException during store", e);
- throw e;
+ throw new StoreException(e);
}
finally
{
@@ -1658,17 +1636,9 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
public void remove()
{
- try
- {
- int delta = getMetaData().getContentSize();
- AbstractBDBMessageStore.this.removeMessage(_messageId, false);
- storedSizeChange(-delta);
-
- }
- catch (AMQStoreException e)
- {
- throw new RuntimeException(e);
- }
+ int delta = getMetaData().getContentSize();
+ AbstractBDBMessageStore.this.removeMessage(_messageId, false);
+ storedSizeChange(-delta);
}
private boolean stored()
@@ -1693,11 +1663,11 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
LOGGER.error("Exception during transaction begin, closing store environment.", e);
closeEnvironmentSafely();
- throw new RuntimeException("Exception during transaction begin, store environment closed.", e);
+ throw new StoreException("Exception during transaction begin, store environment closed.", e);
}
}
- public void enqueueMessage(TransactionLogResource queue, EnqueueableMessage message) throws AMQStoreException
+ public void enqueueMessage(TransactionLogResource queue, EnqueueableMessage message)
{
if(message.getStoredMessage() instanceof StoredBDBMessage)
{
@@ -1709,35 +1679,36 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo
AbstractBDBMessageStore.this.enqueueMessage(_txn, queue, message.getMessageNumber());
}
- public void dequeueMessage(TransactionLogResource queue, EnqueueableMessage message) throws AMQStoreException
+ public void dequeueMessage(TransactionLogResource queue, EnqueueableMessage message)
{
AbstractBDBMessageStore.this.dequeueMessage(_txn, queue, message.getMessageNumber());
}
- public void commitTran() throws AMQStoreException
+ public void commitTran()
{
AbstractBDBMessageStore.this.commitTranImpl(_txn, true);
AbstractBDBMessageStore.this.storedSizeChange(_storeSizeIncrease);
}
- public StoreFuture commitTranAsync() throws AMQStoreException
+ public StoreFuture commitTranAsync()
{
AbstractBDBMessageStore.this.storedSizeChange(_storeSizeIncrease);
return AbstractBDBMessageStore.this.commitTranImpl(_txn, false);
}
- public void abortTran() throws AMQStoreException
+ public void abortTran()
{
AbstractBDBMessageStore.this.abortTran(_txn);
}
- public void removeXid(long format, byte[] globalId, byte[] branchId) throws AMQStoreException
+ public void removeXid(long format, byte[] globalId, byte[] branchId)
{
AbstractBDBMessageStore.this.removeXid(_txn, format, globalId, branchId);
+
}
public void recordXid(long format, byte[] globalId, byte[] branchId, Record[] enqueues,
- Record[] dequeues) throws AMQStoreException
+ Record[] dequeues)
{
AbstractBDBMessageStore.this.recordXid(_txn, format, globalId, branchId, enqueues, dequeues);
}
diff --git a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBBackup.java b/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBBackup.java
index 9b97fec479..80802b6a0c 100644
--- a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBBackup.java
+++ b/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBBackup.java
@@ -26,6 +26,7 @@ import com.sleepycat.je.EnvironmentConfig;
import com.sleepycat.je.util.DbBackup;
import org.apache.log4j.Logger;
+import org.apache.qpid.server.store.StoreException;
import org.apache.qpid.util.CommandLineParser;
import org.apache.qpid.util.FileUtils;
@@ -249,7 +250,7 @@ public class BDBBackup
if (fileSet.length == 0)
{
- throw new RuntimeException("There are no BDB log files to backup in the " + fromdir + " directory.");
+ throw new StoreException("There are no BDB log files to backup in the " + fromdir + " directory.");
}
for (int i = 0; i < fileSet.length; i++)
@@ -272,7 +273,7 @@ public class BDBBackup
catch (IOException ioEx)
{
// Rethrow this as a runtime exception, as something strange has happened.
- throw new RuntimeException(ioEx);
+ throw new StoreException(ioEx);
}
}
}
@@ -292,7 +293,7 @@ public class BDBBackup
long now = System.currentTimeMillis();
if ((now - start) > TIMEOUT)
{
- throw new RuntimeException("Hot backup script failed to complete in " + (TIMEOUT / 1000) + " seconds.");
+ throw new StoreException("Hot backup script failed to complete in " + (TIMEOUT / 1000) + " seconds.");
}
}
@@ -311,7 +312,7 @@ public class BDBBackup
Throwable cause = re.getCause();
if ((cause != null) && (cause instanceof IOException))
{
- throw new RuntimeException(re.getMessage() + " fromDir:" + fromdir + " toDir:" + toDirFile, cause);
+ throw new StoreException(re.getMessage() + " fromDir:" + fromdir + " toDir:" + toDirFile, cause);
}
else
{
@@ -329,7 +330,7 @@ public class BDBBackup
catch (IOException e)
{
// Rethrow this as a runtime exception, as something strange has happened.
- throw new RuntimeException(e);
+ throw new StoreException(e);
}
}
diff --git a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBHAMessageStore.java b/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBHAMessageStore.java
index fb1dc1f1d3..7f119880b0 100644
--- a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBHAMessageStore.java
+++ b/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBHAMessageStore.java
@@ -35,7 +35,7 @@ import java.util.concurrent.Executors;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.log4j.Logger;
-import org.apache.qpid.AMQStoreException;
+import org.apache.qpid.server.store.StoreException;
import org.apache.qpid.server.logging.RootMessageLogger;
import org.apache.qpid.server.logging.actors.AbstractActor;
import org.apache.qpid.server.logging.actors.CurrentActor;
@@ -122,7 +122,7 @@ public class BDBHAMessageStore extends AbstractBDBMessageStore implements HAMess
private Map<String, String> _repConfig;
@Override
- public void configure(VirtualHost virtualHost) throws Exception
+ public void configure(VirtualHost virtualHost)
{
//Mandatory configuration
_groupName = getValidatedStringAttribute(virtualHost, "haGroupName");
@@ -153,7 +153,7 @@ public class BDBHAMessageStore extends AbstractBDBMessageStore implements HAMess
if (_coalescingSync && _durability.getLocalSync() == SyncPolicy.SYNC)
{
- throw new ConfigurationException("Coalescing sync cannot be used with master sync policy " + SyncPolicy.SYNC
+ throw new StoreException("Coalescing sync cannot be used with master sync policy " + SyncPolicy.SYNC
+ "! Please set highAvailability.coalescingSync to false in store configuration.");
}
@@ -162,7 +162,6 @@ public class BDBHAMessageStore extends AbstractBDBMessageStore implements HAMess
private String getValidatedStringAttribute(org.apache.qpid.server.model.VirtualHost virtualHost, String attributeName)
- throws ConfigurationException
{
Object attrValue = virtualHost.getAttribute(attributeName);
if(attrValue != null)
@@ -171,7 +170,7 @@ public class BDBHAMessageStore extends AbstractBDBMessageStore implements HAMess
}
else
{
- throw new ConfigurationException("BDB HA configuration key not found. Please specify configuration attribute: "
+ throw new StoreException("BDB HA configuration key not found. Please specify configuration attribute: "
+ attributeName);
}
}
@@ -206,7 +205,7 @@ public class BDBHAMessageStore extends AbstractBDBMessageStore implements HAMess
@Override
- protected void setupStore(File storePath, String name) throws DatabaseException, AMQStoreException
+ protected void setupStore(File storePath, String name) throws DatabaseException
{
super.setupStore(storePath, name);
@@ -261,7 +260,7 @@ public class BDBHAMessageStore extends AbstractBDBMessageStore implements HAMess
@Override
public void configureMessageStore(VirtualHost virtualHost, MessageStoreRecoveryHandler messageRecoveryHandler,
- TransactionLogRecoveryHandler tlogRecoveryHandler) throws Exception
+ TransactionLogRecoveryHandler tlogRecoveryHandler)
{
super.configureMessageStore(virtualHost, messageRecoveryHandler, tlogRecoveryHandler);
@@ -271,7 +270,7 @@ public class BDBHAMessageStore extends AbstractBDBMessageStore implements HAMess
}
@Override
- public synchronized void activate() throws Exception
+ public synchronized void activate()
{
// Before proceeding, perform a log flush with an fsync
getEnvironment().flushLog(true);
@@ -350,7 +349,7 @@ public class BDBHAMessageStore extends AbstractBDBMessageStore implements HAMess
return members;
}
- public void removeNodeFromGroup(String nodeName) throws AMQStoreException
+ public void removeNodeFromGroup(String nodeName) throws StoreException
{
try
{
@@ -358,15 +357,15 @@ public class BDBHAMessageStore extends AbstractBDBMessageStore implements HAMess
}
catch (OperationFailureException ofe)
{
- throw new AMQStoreException("Failed to remove '" + nodeName + "' from group. " + ofe.getMessage(), ofe);
+ throw new StoreException("Failed to remove '" + nodeName + "' from group. " + ofe.getMessage(), ofe);
}
catch (DatabaseException e)
{
- throw new AMQStoreException("Failed to remove '" + nodeName + "' from group. " + e.getMessage(), e);
+ throw new StoreException("Failed to remove '" + nodeName + "' from group. " + e.getMessage(), e);
}
}
- public void setDesignatedPrimary(boolean isPrimary) throws AMQStoreException
+ public void setDesignatedPrimary(boolean isPrimary) throws StoreException
{
try
{
@@ -385,7 +384,7 @@ public class BDBHAMessageStore extends AbstractBDBMessageStore implements HAMess
}
catch (DatabaseException e)
{
- throw new AMQStoreException("Failed to set '" + _nodeName + "' as designated primary for group. " + e.getMessage(), e);
+ throw new StoreException("Failed to set '" + _nodeName + "' as designated primary for group. " + e.getMessage(), e);
}
}
@@ -394,7 +393,7 @@ public class BDBHAMessageStore extends AbstractBDBMessageStore implements HAMess
return (ReplicatedEnvironment)getEnvironment();
}
- public void updateAddress(String nodeName, String newHostName, int newPort) throws AMQStoreException
+ public void updateAddress(String nodeName, String newHostName, int newPort) throws StoreException
{
try
{
@@ -402,12 +401,12 @@ public class BDBHAMessageStore extends AbstractBDBMessageStore implements HAMess
}
catch (OperationFailureException ofe)
{
- throw new AMQStoreException("Failed to update address for '" + nodeName +
+ throw new StoreException("Failed to update address for '" + nodeName +
"' with new host " + newHostName + " and new port " + newPort + ". " + ofe.getMessage(), ofe);
}
catch (DatabaseException e)
{
- throw new AMQStoreException("Failed to update address for '" + nodeName +
+ throw new StoreException("Failed to update address for '" + nodeName +
"' with new host " + newHostName + " and new port " + newPort + ". " + e.getMessage(), e);
}
}
@@ -441,7 +440,7 @@ public class BDBHAMessageStore extends AbstractBDBMessageStore implements HAMess
}
@Override
- protected void closeInternal() throws Exception
+ protected void closeInternal()
{
substituteNoOpStateChangeListenerOn(getReplicatedEnvironment());
@@ -449,7 +448,14 @@ public class BDBHAMessageStore extends AbstractBDBMessageStore implements HAMess
{
if(_coalescingSync)
{
- _commitThreadWrapper.stopCommitThread();
+ try
+ {
+ _commitThreadWrapper.stopCommitThread();
+ }
+ catch (InterruptedException e)
+ {
+ throw new StoreException(e);
+ }
}
}
finally
@@ -507,7 +513,7 @@ public class BDBHAMessageStore extends AbstractBDBMessageStore implements HAMess
private final Executor _executor = Executors.newSingleThreadExecutor();
@Override
- public void stateChange(StateChangeEvent stateChangeEvent) throws RuntimeException
+ public void stateChange(StateChangeEvent stateChangeEvent)
{
com.sleepycat.je.rep.ReplicatedEnvironment.State state = stateChangeEvent.getState();
@@ -645,7 +651,6 @@ public class BDBHAMessageStore extends AbstractBDBMessageStore implements HAMess
{
@Override
public void stateChange(StateChangeEvent stateChangeEvent)
- throws RuntimeException
{
}
}
diff --git a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHost.java b/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHost.java
index bb3c7b108d..0d50df1bc6 100644
--- a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHost.java
+++ b/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHost.java
@@ -48,14 +48,13 @@ public class BDBHAVirtualHost extends AbstractVirtualHost
org.apache.qpid.server.security.SecurityManager parentSecurityManager,
VirtualHostConfiguration hostConfig,
VirtualHost virtualHost)
- throws Exception
{
super(virtualHostRegistry, brokerStatisticsGatherer, parentSecurityManager, hostConfig, virtualHost);
}
- protected void initialiseStorage(VirtualHostConfiguration hostConfig, VirtualHost virtualHost) throws Exception
+ protected void initialiseStorage(VirtualHostConfiguration hostConfig, VirtualHost virtualHost)
{
_messageStore = new BDBHAMessageStore();
@@ -169,14 +168,7 @@ public class BDBHAVirtualHost extends AbstractVirtualHost
@Override
public void event(Event event)
{
- try
- {
- initialiseModel(getConfiguration());
- }
- catch (Exception e)
- {
- throw new RuntimeException("Failed to initialise virtual host after state change", e);
- }
+ initialiseModel(getConfiguration());
}
}
diff --git a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHostFactory.java b/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHostFactory.java
index 3b564f33fd..7a308920b3 100644
--- a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHostFactory.java
+++ b/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHostFactory.java
@@ -48,7 +48,7 @@ public class BDBHAVirtualHostFactory implements VirtualHostFactory
StatisticsGatherer brokerStatisticsGatherer,
org.apache.qpid.server.security.SecurityManager parentSecurityManager,
VirtualHostConfiguration hostConfig,
- org.apache.qpid.server.model.VirtualHost virtualHost) throws Exception
+ org.apache.qpid.server.model.VirtualHost virtualHost)
{
return new BDBHAVirtualHost(virtualHostRegistry,
brokerStatisticsGatherer,
diff --git a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java b/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java
index 4028de4b80..acff8e2b21 100644
--- a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java
+++ b/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java
@@ -23,8 +23,8 @@ package org.apache.qpid.server.store.berkeleydb;
import java.io.File;
import org.apache.log4j.Logger;
-import org.apache.qpid.AMQStoreException;
import org.apache.qpid.server.store.MessageStore;
+import org.apache.qpid.server.store.StoreException;
import org.apache.qpid.server.store.StoreFuture;
import com.sleepycat.je.DatabaseException;
@@ -46,7 +46,7 @@ public class BDBMessageStore extends AbstractBDBMessageStore
private CommitThreadWrapper _commitThreadWrapper;
@Override
- protected void setupStore(File storePath, String name) throws DatabaseException, AMQStoreException
+ protected void setupStore(File storePath, String name) throws DatabaseException
{
super.setupStore(storePath, name);
@@ -79,9 +79,16 @@ public class BDBMessageStore extends AbstractBDBMessageStore
}
@Override
- protected void closeInternal() throws Exception
+ protected void closeInternal()
{
- _commitThreadWrapper.stopCommitThread();
+ try
+ {
+ _commitThreadWrapper.stopCommitThread();
+ }
+ catch (InterruptedException e)
+ {
+ throw new StoreException(e);
+ }
super.closeInternal();
}
diff --git a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/CommitThreadWrapper.java b/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/CommitThreadWrapper.java
index 598d20146c..1f05dca41a 100644
--- a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/CommitThreadWrapper.java
+++ b/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/CommitThreadWrapper.java
@@ -25,6 +25,7 @@ import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.log4j.Logger;
+import org.apache.qpid.server.store.StoreException;
import org.apache.qpid.server.store.StoreFuture;
import com.sleepycat.je.CheckpointConfig;
@@ -139,7 +140,7 @@ public class CommitThreadWrapper
}
catch (InterruptedException e)
{
- throw new RuntimeException(e);
+ throw new StoreException(e);
}
}
diff --git a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/FieldTableEncoding.java b/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/FieldTableEncoding.java
index a876a056fc..e3cbeccd6e 100644
--- a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/FieldTableEncoding.java
+++ b/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/FieldTableEncoding.java
@@ -25,6 +25,7 @@ import com.sleepycat.bind.tuple.TupleOutput;
import com.sleepycat.je.DatabaseException;
import org.apache.qpid.framing.FieldTable;
+import org.apache.qpid.server.store.StoreException;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
@@ -55,7 +56,7 @@ public class FieldTableEncoding
}
catch (IOException e)
{
- throw new RuntimeException(e);
+ throw new StoreException(e);
}
}
diff --git a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuple/ConfiguredObjectBinding.java b/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuple/ConfiguredObjectBinding.java
index 31cafbe74d..a408732e2f 100644
--- a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuple/ConfiguredObjectBinding.java
+++ b/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuple/ConfiguredObjectBinding.java
@@ -29,6 +29,7 @@ import org.apache.qpid.server.store.ConfiguredObjectRecord;
import com.sleepycat.bind.tuple.TupleBinding;
import com.sleepycat.bind.tuple.TupleInput;
import com.sleepycat.bind.tuple.TupleOutput;
+import org.apache.qpid.server.store.StoreException;
import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
@@ -63,7 +64,7 @@ public class ConfiguredObjectBinding extends TupleBinding<ConfiguredObjectRecord
catch (IOException e)
{
//should never happen
- throw new RuntimeException(e);
+ throw new StoreException(e);
}
}
@@ -79,15 +80,15 @@ public class ConfiguredObjectBinding extends TupleBinding<ConfiguredObjectRecord
}
catch (JsonMappingException e)
{
- throw new RuntimeException(e);
+ throw new StoreException(e);
}
catch (JsonGenerationException e)
{
- throw new RuntimeException(e);
+ throw new StoreException(e);
}
catch (IOException e)
{
- throw new RuntimeException(e);
+ throw new StoreException(e);
}
}
diff --git a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/StoreUpgrade.java b/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/StoreUpgrade.java
index f73e2e5d78..adcaef35ef 100644
--- a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/StoreUpgrade.java
+++ b/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/StoreUpgrade.java
@@ -20,12 +20,9 @@
*/
package org.apache.qpid.server.store.berkeleydb.upgrade;
-import com.sleepycat.je.DatabaseException;
import com.sleepycat.je.Environment;
-import org.apache.qpid.AMQStoreException;
public interface StoreUpgrade
{
- void performUpgrade(Environment environment, UpgradeInteractionHandler handler, String virtualHostName)
- throws DatabaseException, AMQStoreException;
+ void performUpgrade(Environment environment, UpgradeInteractionHandler handler, String virtualHostName);
}
diff --git a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom4To5.java b/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom4To5.java
index 14793cbfd3..87f8afde4a 100644
--- a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom4To5.java
+++ b/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom4To5.java
@@ -31,7 +31,6 @@ import java.util.List;
import java.util.Set;
import org.apache.log4j.Logger;
-import org.apache.qpid.AMQStoreException;
import org.apache.qpid.common.AMQPFilterTypes;
import org.apache.qpid.exchange.ExchangeDefaults;
import org.apache.qpid.framing.AMQFrameDecodingException;
@@ -41,6 +40,7 @@ import org.apache.qpid.framing.ContentHeaderBody;
import org.apache.qpid.framing.FieldTable;
import org.apache.qpid.framing.abstraction.MessagePublishInfo;
import org.apache.qpid.server.protocol.v0_8.MessageMetaData;
+import org.apache.qpid.server.store.StoreException;
import org.apache.qpid.server.store.StorableMessageMetaData;
import org.apache.qpid.server.store.berkeleydb.AMQShortStringEncoding;
import org.apache.qpid.server.store.berkeleydb.FieldTableEncoding;
@@ -53,7 +53,6 @@ import com.sleepycat.bind.tuple.TupleInput;
import com.sleepycat.bind.tuple.TupleOutput;
import com.sleepycat.je.Database;
import com.sleepycat.je.DatabaseEntry;
-import com.sleepycat.je.DatabaseException;
import com.sleepycat.je.Environment;
import com.sleepycat.je.Transaction;
@@ -75,45 +74,25 @@ public class UpgradeFrom4To5 extends AbstractStoreUpgrade
private static final Logger _logger = Logger.getLogger(UpgradeFrom4To5.class);
- public void performUpgrade(final Environment environment, final UpgradeInteractionHandler handler, String virtualHostName) throws DatabaseException, AMQStoreException
+ public void performUpgrade(final Environment environment, final UpgradeInteractionHandler handler, String virtualHostName)
{
Transaction transaction = null;
- try
- {
- reportStarting(environment, 4);
-
- transaction = environment.beginTransaction(null, null);
+ reportStarting(environment, 4);
- // find all queues which are bound to a topic exchange and which have a colon in their name
- final List<AMQShortString> potentialDurableSubs = findPotentialDurableSubscriptions(environment, transaction);
+ transaction = environment.beginTransaction(null, null);
- Set<String> existingQueues = upgradeQueues(environment, handler, potentialDurableSubs, transaction);
- upgradeQueueBindings(environment, handler, potentialDurableSubs, transaction);
- Set<Long> messagesToDiscard = upgradeDelivery(environment, existingQueues, handler, transaction);
- upgradeContent(environment, handler, messagesToDiscard, transaction);
- upgradeMetaData(environment, handler, messagesToDiscard, transaction);
- renameRemainingDatabases(environment, handler, transaction);
- transaction.commit();
+ // find all queues which are bound to a topic exchange and which have a colon in their name
+ final List<AMQShortString> potentialDurableSubs = findPotentialDurableSubscriptions(environment, transaction);
- reportFinished(environment, 5);
+ Set<String> existingQueues = upgradeQueues(environment, handler, potentialDurableSubs, transaction);
+ upgradeQueueBindings(environment, handler, potentialDurableSubs, transaction);
+ Set<Long> messagesToDiscard = upgradeDelivery(environment, existingQueues, handler, transaction);
+ upgradeContent(environment, handler, messagesToDiscard, transaction);
+ upgradeMetaData(environment, handler, messagesToDiscard, transaction);
+ renameRemainingDatabases(environment, handler, transaction);
+ transaction.commit();
- }
- catch (Exception e)
- {
- transaction.abort();
- if (e instanceof DatabaseException)
- {
- throw (DatabaseException) e;
- }
- else if (e instanceof AMQStoreException)
- {
- throw (AMQStoreException) e;
- }
- else
- {
- throw new AMQStoreException("Unexpected exception", e);
- }
- }
+ reportFinished(environment, 5);
}
private void upgradeQueueBindings(Environment environment, UpgradeInteractionHandler handler, final List<AMQShortString> potentialDurableSubs,
@@ -275,7 +254,7 @@ public class UpgradeFrom4To5 extends AbstractStoreUpgrade
}
else
{
- throw new RuntimeException("Unable is aborted!");
+ throw new StoreException("Unable is aborted!");
}
}
}
diff --git a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom5To6.java b/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom5To6.java
index a478872ad0..9b1ab7057b 100644
--- a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom5To6.java
+++ b/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom5To6.java
@@ -36,7 +36,6 @@ import java.util.TreeMap;
import java.util.UUID;
import org.apache.log4j.Logger;
-import org.apache.qpid.AMQStoreException;
import org.apache.qpid.exchange.ExchangeDefaults;
import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.framing.FieldTable;
@@ -45,8 +44,8 @@ import org.apache.qpid.server.model.Exchange;
import org.apache.qpid.server.model.LifetimePolicy;
import org.apache.qpid.server.model.Queue;
import org.apache.qpid.server.model.UUIDGenerator;
-import org.apache.qpid.server.queue.AMQQueueFactory;
import org.apache.qpid.server.queue.QueueArgumentsConverter;
+import org.apache.qpid.server.store.StoreException;
import org.apache.qpid.server.store.berkeleydb.AMQShortStringEncoding;
import org.apache.qpid.server.store.berkeleydb.FieldTableEncoding;
import org.apache.qpid.server.util.MapJsonSerializer;
@@ -59,7 +58,6 @@ import com.sleepycat.je.Cursor;
import com.sleepycat.je.CursorConfig;
import com.sleepycat.je.Database;
import com.sleepycat.je.DatabaseEntry;
-import com.sleepycat.je.DatabaseException;
import com.sleepycat.je.Environment;
import com.sleepycat.je.LockMode;
import com.sleepycat.je.OperationStatus;
@@ -121,7 +119,6 @@ public class UpgradeFrom5To6 extends AbstractStoreUpgrade
* in "CONFIGURED_OBJECTS" table.
*/
public void performUpgrade(final Environment environment, final UpgradeInteractionHandler handler, String virtualHostName)
- throws DatabaseException, AMQStoreException
{
reportStarting(environment, 5);
upgradeMessages(environment, handler);
@@ -131,61 +128,21 @@ public class UpgradeFrom5To6 extends AbstractStoreUpgrade
}
private void upgradeConfiguredObjectsAndDependencies(Environment environment, UpgradeInteractionHandler handler, String virtualHostName)
- throws AMQStoreException
{
Transaction transaction = null;
- try
- {
- transaction = environment.beginTransaction(null, null);
- upgradeConfiguredObjects(environment, handler, transaction, virtualHostName);
- upgradeQueueEntries(environment, transaction, virtualHostName);
- upgradeXidEntries(environment, transaction, virtualHostName);
- transaction.commit();
- }
- catch (Exception e)
- {
- transaction.abort();
- if (e instanceof DatabaseException)
- {
- throw (DatabaseException) e;
- }
- else if (e instanceof AMQStoreException)
- {
- throw (AMQStoreException) e;
- }
- else
- {
- throw new AMQStoreException("Unexpected exception", e);
- }
- }
+ transaction = environment.beginTransaction(null, null);
+ upgradeConfiguredObjects(environment, handler, transaction, virtualHostName);
+ upgradeQueueEntries(environment, transaction, virtualHostName);
+ upgradeXidEntries(environment, transaction, virtualHostName);
+ transaction.commit();
}
private void upgradeMessages(final Environment environment, final UpgradeInteractionHandler handler)
- throws AMQStoreException
{
Transaction transaction = null;
- try
- {
- transaction = environment.beginTransaction(null, null);
- upgradeMessages(environment, handler, transaction);
- transaction.commit();
- }
- catch (Exception e)
- {
- transaction.abort();
- if (e instanceof DatabaseException)
- {
- throw (DatabaseException) e;
- }
- else if (e instanceof AMQStoreException)
- {
- throw (AMQStoreException) e;
- }
- else
- {
- throw new AMQStoreException("Unexpected exception", e);
- }
- }
+ transaction = environment.beginTransaction(null, null);
+ upgradeMessages(environment, handler, transaction);
+ transaction.commit();
}
private void renameDatabases(Environment environment, Transaction transaction)
@@ -207,7 +164,7 @@ public class UpgradeFrom5To6 extends AbstractStoreUpgrade
}
private void upgradeMessages(final Environment environment, final UpgradeInteractionHandler handler,
- final Transaction transaction) throws AMQStoreException
+ final Transaction transaction)
{
_logger.info("Message Contents");
if (environment.getDatabaseNames().contains(OLD_CONTENT_DB_NAME))
@@ -285,7 +242,7 @@ public class UpgradeFrom5To6 extends AbstractStoreUpgrade
return;
case ABORT:
_logger.error(message);
- throw new RuntimeException("Unable to upgrade message " + messageId);
+ throw new StoreException("Unable to upgrade message " + messageId);
}
}
@@ -356,7 +313,6 @@ public class UpgradeFrom5To6 extends AbstractStoreUpgrade
}
private void upgradeConfiguredObjects(Environment environment, UpgradeInteractionHandler handler, Transaction transaction, String virtualHostName)
- throws AMQStoreException
{
upgradeQueues(environment, transaction, virtualHostName);
upgradeExchanges(environment, transaction, virtualHostName);
@@ -640,7 +596,7 @@ public class UpgradeFrom5To6 extends AbstractStoreUpgrade
OperationStatus status = database.put(txn, key, value);
if (status != OperationStatus.SUCCESS)
{
- throw new RuntimeException("Cannot add record into " + database.getDatabaseName() + ":" + status);
+ throw new StoreException("Cannot add record into " + database.getDatabaseName() + ":" + status);
}
}
diff --git a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom6To7.java b/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom6To7.java
index e318c3586e..ce00fd1a48 100644
--- a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom6To7.java
+++ b/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom6To7.java
@@ -25,10 +25,9 @@ import com.sleepycat.bind.tuple.IntegerBinding;
import com.sleepycat.je.Database;
import com.sleepycat.je.DatabaseConfig;
import com.sleepycat.je.DatabaseEntry;
-import com.sleepycat.je.DatabaseException;
import com.sleepycat.je.Environment;
import com.sleepycat.je.OperationStatus;
-import org.apache.qpid.AMQStoreException;
+import org.apache.qpid.server.store.StoreException;
public class UpgradeFrom6To7 extends AbstractStoreUpgrade
{
@@ -37,7 +36,6 @@ public class UpgradeFrom6To7 extends AbstractStoreUpgrade
@Override
public void performUpgrade(Environment environment, UpgradeInteractionHandler handler, String virtualHostName)
- throws DatabaseException, AMQStoreException
{
reportStarting(environment, 6);
DatabaseConfig dbConfig = new DatabaseConfig();
@@ -55,7 +53,7 @@ public class UpgradeFrom6To7 extends AbstractStoreUpgrade
OperationStatus status = versionDb.put(null, key, value);
if (status != OperationStatus.SUCCESS)
{
- throw new AMQStoreException("Error initialising config version: " + status);
+ throw new StoreException("Error initialising config version: " + status);
}
}
diff --git a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/Upgrader.java b/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/Upgrader.java
index e769bfae81..4d536a2f95 100644
--- a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/Upgrader.java
+++ b/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/Upgrader.java
@@ -24,7 +24,7 @@ import com.sleepycat.je.Cursor;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
-import org.apache.qpid.AMQStoreException;
+import org.apache.qpid.server.store.StoreException;
import org.apache.qpid.server.store.berkeleydb.AbstractBDBMessageStore;
import com.sleepycat.bind.tuple.IntegerBinding;
@@ -34,7 +34,6 @@ import com.sleepycat.je.DatabaseConfig;
import com.sleepycat.je.DatabaseEntry;
import com.sleepycat.je.DatabaseException;
import com.sleepycat.je.Environment;
-import com.sleepycat.je.LockMode;
import com.sleepycat.je.OperationStatus;
public class Upgrader
@@ -50,7 +49,7 @@ public class Upgrader
_virtualHostName = virtualHostName;
}
- public void upgradeIfNecessary() throws AMQStoreException
+ public void upgradeIfNecessary()
{
boolean isEmpty = _environment.getDatabaseNames().isEmpty();
DatabaseConfig dbConfig = new DatabaseConfig();
@@ -76,7 +75,7 @@ public class Upgrader
int version = getSourceVersion(versionDb);
if(version > AbstractBDBMessageStore.VERSION)
{
- throw new AMQStoreException("Database version " + version
+ throw new StoreException("Database version " + version
+ " is higher than the most recent known version: "
+ AbstractBDBMessageStore.VERSION);
}
@@ -125,7 +124,6 @@ public class Upgrader
}
void performUpgradeFromVersion(int sourceVersion, Database versionDb)
- throws AMQStoreException
{
while(sourceVersion != AbstractBDBMessageStore.VERSION)
{
@@ -138,7 +136,7 @@ public class Upgrader
}
}
- void upgrade(final int fromVersion, final int toVersion) throws AMQStoreException
+ void upgrade(final int fromVersion, final int toVersion)
{
try
{
@@ -152,27 +150,27 @@ public class Upgrader
}
catch (ClassNotFoundException e)
{
- throw new AMQStoreException("Unable to upgrade BDB data store from version " + fromVersion + " to version"
+ throw new StoreException("Unable to upgrade BDB data store from version " + fromVersion + " to version"
+ toVersion, e);
}
catch (NoSuchMethodException e)
{
- throw new AMQStoreException("Unable to upgrade BDB data store from version " + fromVersion + " to version"
+ throw new StoreException("Unable to upgrade BDB data store from version " + fromVersion + " to version"
+ toVersion, e);
}
catch (InvocationTargetException e)
{
- throw new AMQStoreException("Unable to upgrade BDB data store from version " + fromVersion + " to version"
+ throw new StoreException("Unable to upgrade BDB data store from version " + fromVersion + " to version"
+ toVersion, e);
}
catch (InstantiationException e)
{
- throw new AMQStoreException("Unable to upgrade BDB data store from version " + fromVersion + " to version"
+ throw new StoreException("Unable to upgrade BDB data store from version " + fromVersion + " to version"
+ toVersion, e);
}
catch (IllegalAccessException e)
{
- throw new AMQStoreException("Unable to upgrade BDB data store from version " + fromVersion + " to version"
+ throw new StoreException("Unable to upgrade BDB data store from version " + fromVersion + " to version"
+ toVersion, e);
}
}
diff --git a/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/HAMessageStoreSmokeTest.java b/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/HAMessageStoreSmokeTest.java
index 3f32df4b0c..7f7b65f315 100644
--- a/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/HAMessageStoreSmokeTest.java
+++ b/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/HAMessageStoreSmokeTest.java
@@ -21,6 +21,7 @@ package org.apache.qpid.server.store.berkeleydb;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.qpid.server.model.VirtualHost;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
import org.apache.qpid.test.utils.QpidTestCase;
import static org.mockito.Mockito.mock;
@@ -36,7 +37,7 @@ public class HAMessageStoreSmokeTest extends QpidTestCase
_store.configure(mock(VirtualHost.class));
fail("Expected an exception to be thrown");
}
- catch (ConfigurationException ce)
+ catch (ServerScopedRuntimeException ce)
{
assertTrue(ce.getMessage().contains("BDB HA configuration key not found"));
}
diff --git a/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgraderFailOnNewerVersionTest.java b/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgraderFailOnNewerVersionTest.java
index 75717120b3..400ac12792 100644
--- a/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgraderFailOnNewerVersionTest.java
+++ b/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgraderFailOnNewerVersionTest.java
@@ -21,21 +21,13 @@
package org.apache.qpid.server.store.berkeleydb.upgrade;
import com.sleepycat.bind.tuple.IntegerBinding;
-import com.sleepycat.bind.tuple.LongBinding;
import com.sleepycat.je.Cursor;
import com.sleepycat.je.Database;
import com.sleepycat.je.DatabaseConfig;
import com.sleepycat.je.DatabaseEntry;
-import com.sleepycat.je.Environment;
-import com.sleepycat.je.EnvironmentConfig;
import com.sleepycat.je.OperationStatus;
-import com.sleepycat.je.Transaction;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.qpid.AMQStoreException;
import org.apache.qpid.server.store.berkeleydb.AbstractBDBMessageStore;
-import org.apache.qpid.server.store.berkeleydb.tuple.ContentBinding;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
public class UpgraderFailOnNewerVersionTest extends AbstractUpgradeTestCase
{
@@ -99,7 +91,7 @@ public class UpgraderFailOnNewerVersionTest extends AbstractUpgradeTestCase
_upgrader.upgradeIfNecessary();
fail("Store should not be able to be upgraded");
}
- catch(AMQStoreException ex)
+ catch(ServerScopedRuntimeException ex)
{
assertEquals("Incorrect exception thrown", "Database version 999 is higher than the most recent known version: "
+ AbstractBDBMessageStore.VERSION, ex.getMessage());
diff --git a/java/bdbstore/systests/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreTest.java b/java/bdbstore/systests/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreTest.java
index cecd39381e..eb3b665242 100644
--- a/java/bdbstore/systests/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreTest.java
+++ b/java/bdbstore/systests/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreTest.java
@@ -25,7 +25,7 @@ import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
-import org.apache.qpid.AMQStoreException;
+import org.apache.qpid.server.store.StoreException;
import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.framing.BasicContentHeaderProperties;
import org.apache.qpid.framing.ContentHeaderBody;
@@ -361,7 +361,7 @@ public class BDBMessageStoreTest extends MessageStoreTest
bdbStore.getMessageMetaData(messageid_0_8);
fail("No exception thrown when message id not found getting metadata");
}
- catch (AMQStoreException e)
+ catch (StoreException e)
{
// pass since exception expected
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/TransactionTimeoutHelper.java b/java/broker-core/src/main/java/org/apache/qpid/server/TransactionTimeoutHelper.java
index b7007bf768..13f4fbf254 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/TransactionTimeoutHelper.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/TransactionTimeoutHelper.java
@@ -18,7 +18,6 @@
*/
package org.apache.qpid.server;
-import org.apache.qpid.AMQException;
import org.apache.qpid.server.logging.LogActor;
import org.apache.qpid.server.logging.LogMessage;
import org.apache.qpid.server.logging.LogSubject;
@@ -41,7 +40,7 @@ public class TransactionTimeoutHelper
_closeAction = closeAction;
}
- public void checkIdleOrOpenTimes(ServerTransaction transaction, long openWarn, long openClose, long idleWarn, long idleClose) throws AMQException
+ public void checkIdleOrOpenTimes(ServerTransaction transaction, long openWarn, long openClose, long idleWarn, long idleClose)
{
if (transaction.isTransactional())
{
@@ -70,7 +69,7 @@ public class TransactionTimeoutHelper
*/
private boolean logAndCloseIfNecessary(final long timeSoFar,
final long warnTimeout, final long closeTimeout,
- final LogMessage warnMessage, final String closeMessage) throws AMQException
+ final LogMessage warnMessage, final String closeMessage)
{
if (isTimedOut(timeSoFar, warnTimeout))
{
@@ -96,7 +95,7 @@ public class TransactionTimeoutHelper
public interface CloseAction
{
- void doTimeoutAction(String reason) throws AMQException;
+ void doTimeoutAction(String reason);
}
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java b/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java
index df82822a86..d6c46ee7d9 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java
@@ -28,6 +28,7 @@ import java.util.UUID;
import org.apache.qpid.server.configuration.ConfigurationEntry;
import org.apache.qpid.server.configuration.ConfigurationEntryStore;
import org.apache.qpid.server.configuration.IllegalConfigurationException;
+import org.apache.qpid.server.store.StoreException;
public class JsonConfigurationEntryStore extends MemoryConfigurationEntryStore
{
@@ -49,7 +50,7 @@ public class JsonConfigurationEntryStore extends MemoryConfigurationEntryStore
{
if(!_storeFile.delete())
{
- throw new RuntimeException("Unable to overwrite existing configuration store file as requested: " + storeLocation);
+ throw new StoreException("Unable to overwrite existing configuration store file as requested: " + storeLocation);
}
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/StoreConfigurationChangeListener.java b/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/StoreConfigurationChangeListener.java
index 6cd3447ebd..e030d50e56 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/StoreConfigurationChangeListener.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/StoreConfigurationChangeListener.java
@@ -37,6 +37,7 @@ import org.apache.qpid.server.model.Model;
import org.apache.qpid.server.model.Port;
import org.apache.qpid.server.model.State;
import org.apache.qpid.server.model.VirtualHost;
+import org.apache.qpid.server.store.StoreException;
public class StoreConfigurationChangeListener implements ConfigurationChangeListener
{
@@ -148,7 +149,7 @@ public class StoreConfigurationChangeListener implements ConfigurationChangeList
if (interfaces.size() == 0)
{
- throw new RuntimeException("Can not identify the configured object type");
+ throw new StoreException("Can not identify the configured object type");
}
if (interfaces.size() == 1)
@@ -185,7 +186,7 @@ public class StoreConfigurationChangeListener implements ConfigurationChangeList
}
else
{
- throw new RuntimeException("Can not identify the configured object type as an it implements"
+ throw new StoreException("Can not identify the configured object type as an it implements"
+ " more than one configured object interfaces: " + interfaces);
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/configuration/updater/ChangeAttributesTask.java b/java/broker-core/src/main/java/org/apache/qpid/server/configuration/updater/ChangeAttributesTask.java
index 4ba4057fee..fb672635b4 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/configuration/updater/ChangeAttributesTask.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/configuration/updater/ChangeAttributesTask.java
@@ -25,7 +25,7 @@ import java.util.concurrent.Callable;
import org.apache.qpid.server.model.ConfiguredObject;
-public class ChangeAttributesTask implements Callable<Void>
+public class ChangeAttributesTask implements TaskExecutor.Task<Void>
{
private final Map<String, Object> _attributes;
private final ConfiguredObject _object;
@@ -38,7 +38,7 @@ public class ChangeAttributesTask implements Callable<Void>
}
@Override
- public Void call() throws Exception
+ public Void call()
{
_object.setAttributes(_attributes);
return null;
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/configuration/updater/ChangeStateTask.java b/java/broker-core/src/main/java/org/apache/qpid/server/configuration/updater/ChangeStateTask.java
index b6de1e136a..42ce1d8c03 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/configuration/updater/ChangeStateTask.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/configuration/updater/ChangeStateTask.java
@@ -25,7 +25,7 @@ import java.util.concurrent.Callable;
import org.apache.qpid.server.model.ConfiguredObject;
import org.apache.qpid.server.model.State;
-public final class ChangeStateTask implements Callable<State>
+public final class ChangeStateTask implements TaskExecutor.Task<State>
{
private ConfiguredObject _object;
private State _expectedState;
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/configuration/updater/CreateChildTask.java b/java/broker-core/src/main/java/org/apache/qpid/server/configuration/updater/CreateChildTask.java
index d3a8f5b797..27bc6d73f6 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/configuration/updater/CreateChildTask.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/configuration/updater/CreateChildTask.java
@@ -26,7 +26,7 @@ import java.util.concurrent.Callable;
import org.apache.qpid.server.model.ConfiguredObject;
-public final class CreateChildTask implements Callable<ConfiguredObject>
+public final class CreateChildTask implements TaskExecutor.Task<ConfiguredObject>
{
private ConfiguredObject _object;
private Class<? extends ConfiguredObject> _childClass;
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/configuration/updater/SetAttributeTask.java b/java/broker-core/src/main/java/org/apache/qpid/server/configuration/updater/SetAttributeTask.java
index 94649434e6..f8d29c368b 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/configuration/updater/SetAttributeTask.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/configuration/updater/SetAttributeTask.java
@@ -24,7 +24,7 @@ import java.util.concurrent.Callable;
import org.apache.qpid.server.model.ConfiguredObject;
-public final class SetAttributeTask implements Callable<Object>
+public final class SetAttributeTask implements TaskExecutor.Task<Object>
{
private ConfiguredObject _object;
private String _attributeName;
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/configuration/updater/TaskExecutor.java b/java/broker-core/src/main/java/org/apache/qpid/server/configuration/updater/TaskExecutor.java
index 22863c089e..3104df6b00 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/configuration/updater/TaskExecutor.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/configuration/updater/TaskExecutor.java
@@ -42,6 +42,7 @@ import org.apache.qpid.server.logging.LogActor;
import org.apache.qpid.server.logging.actors.CurrentActor;
import org.apache.qpid.server.model.State;
import org.apache.qpid.server.security.SecurityManager;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
public class TaskExecutor
{
@@ -52,6 +53,11 @@ public class TaskExecutor
private final AtomicReference<State> _state;
private volatile ExecutorService _executor;
+ public static interface Task<X> extends Callable<X>
+ {
+ X call();
+ }
+
public TaskExecutor()
{
_state = new AtomicReference<State>(State.INITIALISING);
@@ -122,17 +128,17 @@ public class TaskExecutor
}
}
- Future<?> submit(Callable<?> task)
+ <T> Future<T> submit(Task<T> task)
{
checkState();
if (LOGGER.isDebugEnabled())
{
LOGGER.debug("Submitting task: " + task);
}
- Future<?> future = null;
+ Future<T> future = null;
if (isTaskExecutorThread())
{
- Object result = executeTaskAndHandleExceptions(task);
+ T result = executeTask(task);
return new ImmediateFuture(result);
}
else
@@ -142,16 +148,16 @@ public class TaskExecutor
return future;
}
- public Object submitAndWait(Callable<?> task) throws CancellationException
+ public <T> T submitAndWait(Task<T> task) throws CancellationException
{
try
{
- Future<?> future = submit(task);
+ Future<T> future = submit(task);
return future.get();
}
catch (InterruptedException e)
{
- throw new RuntimeException("Task execution was interrupted: " + task, e);
+ throw new ServerScopedRuntimeException("Task execution was interrupted: " + task, e);
}
catch (ExecutionException e)
{
@@ -162,7 +168,7 @@ public class TaskExecutor
}
else if (cause instanceof Exception)
{
- throw new RuntimeException("Failed to execute user task: " + task, cause);
+ throw new ServerScopedRuntimeException("Failed to execute user task: " + task, cause);
}
else if (cause instanceof Error)
{
@@ -170,7 +176,7 @@ public class TaskExecutor
}
else
{
- throw new RuntimeException("Failed to execute user task: " + task, cause);
+ throw new ServerScopedRuntimeException("Failed to execute user task: " + task, cause);
}
}
}
@@ -188,29 +194,13 @@ public class TaskExecutor
}
}
- private Object executeTaskAndHandleExceptions(Callable<?> userTask)
- {
- try
- {
- return executeTask(userTask);
- }
- catch (Exception e)
- {
- if (e instanceof RuntimeException)
- {
- throw (RuntimeException) e;
- }
- throw new RuntimeException("Failed to execute user task: " + userTask, e);
- }
- }
-
- private Object executeTask(Callable<?> userTask) throws Exception
+ private <T> T executeTask(Task<T> userTask)
{
if (LOGGER.isDebugEnabled())
{
LOGGER.debug("Performing task " + userTask);
}
- Object result = userTask.call();
+ T result = userTask.call();
if (LOGGER.isDebugEnabled())
{
LOGGER.debug("Task " + userTask + " is performed successfully with result:" + result);
@@ -218,14 +208,14 @@ public class TaskExecutor
return result;
}
- private class CallableWrapper implements Callable<Object>
+ private class CallableWrapper<T> implements Task<T>
{
- private Callable<?> _userTask;
+ private Task<T> _userTask;
private Subject _securityManagerSubject;
private LogActor _actor;
private Subject _contextSubject;
- public CallableWrapper(Callable<?> userWork)
+ public CallableWrapper(Task<T> userWork)
{
_userTask = userWork;
_securityManagerSubject = SecurityManager.getThreadSubject();
@@ -234,20 +224,20 @@ public class TaskExecutor
}
@Override
- public Object call() throws Exception
+ public T call()
{
SecurityManager.setThreadSubject(_securityManagerSubject);
CurrentActor.set(_actor);
try
{
- Object result = null;
+ T result = null;
try
{
- result = Subject.doAs(_contextSubject, new PrivilegedExceptionAction<Object>()
+ result = Subject.doAs(_contextSubject, new PrivilegedExceptionAction<T>()
{
@Override
- public Object run() throws Exception
+ public T run() throws Exception
{
return executeTask(_userTask);
}
@@ -255,7 +245,15 @@ public class TaskExecutor
}
catch (PrivilegedActionException e)
{
- throw e.getException();
+ Exception underlying = e.getException();
+ if(underlying instanceof RuntimeException)
+ {
+ throw (RuntimeException)underlying;
+ }
+ else
+ {
+ throw new ServerScopedRuntimeException(e);
+ }
}
return result;
}
@@ -281,11 +279,11 @@ public class TaskExecutor
}
}
- private class ImmediateFuture implements Future<Object>
+ private class ImmediateFuture<T> implements Future<T>
{
- private Object _result;
+ private T _result;
- public ImmediateFuture(Object result)
+ public ImmediateFuture(T result)
{
super();
this._result = result;
@@ -310,13 +308,13 @@ public class TaskExecutor
}
@Override
- public Object get()
+ public T get()
{
return _result;
}
@Override
- public Object get(long timeout, TimeUnit unit)
+ public T get(long timeout, TimeUnit unit)
{
return get();
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/connection/IConnectionRegistry.java b/java/broker-core/src/main/java/org/apache/qpid/server/connection/IConnectionRegistry.java
index 77febd9312..209e2739f4 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/connection/IConnectionRegistry.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/connection/IConnectionRegistry.java
@@ -20,8 +20,6 @@
*/
package org.apache.qpid.server.connection;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.protocol.AMQConstant;
import org.apache.qpid.server.protocol.AMQConnectionModel;
import java.util.List;
@@ -33,7 +31,7 @@ public interface IConnectionRegistry
public void initialise();
- public void close() throws AMQException;
+ public void close();
public void close(String replyText);
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/consumer/Consumer.java b/java/broker-core/src/main/java/org/apache/qpid/server/consumer/Consumer.java
index e082d6eee4..e23eb397e1 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/consumer/Consumer.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/consumer/Consumer.java
@@ -21,11 +21,7 @@
package org.apache.qpid.server.consumer;
import java.util.concurrent.atomic.AtomicLong;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.server.logging.LogActor;
-import org.apache.qpid.server.message.MessageInstance;
import org.apache.qpid.server.protocol.AMQSessionModel;
-import org.apache.qpid.server.util.StateChangeListener;
public interface Consumer
{
@@ -64,7 +60,7 @@ public interface Consumer
boolean seesRequeues();
- void close() throws AMQException;
+ void close();
boolean trySendLock();
@@ -77,5 +73,5 @@ public interface Consumer
String getName();
- void flush() throws AMQException;
+ void flush();
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/consumer/ConsumerTarget.java b/java/broker-core/src/main/java/org/apache/qpid/server/consumer/ConsumerTarget.java
index 92579475ed..8f6b008f9b 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/consumer/ConsumerTarget.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/consumer/ConsumerTarget.java
@@ -20,7 +20,6 @@
*/
package org.apache.qpid.server.consumer;
-import org.apache.qpid.AMQException;
import org.apache.qpid.server.message.MessageInstance;
import org.apache.qpid.server.message.ServerMessage;
import org.apache.qpid.server.protocol.AMQSessionModel;
@@ -49,13 +48,13 @@ public interface ConsumerTarget
AMQSessionModel getSessionModel();
- void send(MessageInstance entry, boolean batch) throws AMQException;
+ void send(MessageInstance entry, boolean batch);
void flushBatched();
void queueDeleted();
- void queueEmpty() throws AMQException;
+ void queueEmpty();
boolean allocateCredit(ServerMessage msg);
diff --git a/java/common/src/main/java/org/apache/qpid/AMQUnknownExchangeType.java b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AMQUnknownExchangeType.java
index 0eefc03016..2e39973c11 100644
--- a/java/common/src/main/java/org/apache/qpid/AMQUnknownExchangeType.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AMQUnknownExchangeType.java
@@ -19,7 +19,7 @@
*
*/
-package org.apache.qpid;
+package org.apache.qpid.server.exchange;
/**
* AMQUnknownExchangeType represents coding error where unknown exchange type requested from exchange factory.
@@ -29,15 +29,13 @@ package org.apache.qpid;
* <tr><td> Represents unknown exchange type request.
* <tr><td>
*
- * @todo Not an AMQP exception as no status code.
- *
* @todo Represent coding error, where unknown exchange type is requested by passing a string parameter. Use a type safe
* enum for the exchange type, or replace with IllegalArgumentException. Should be runtime.
*/
-public class AMQUnknownExchangeType extends AMQException
+public class AMQUnknownExchangeType extends Exception
{
public AMQUnknownExchangeType(String message, Throwable cause)
{
- super(null, message, cause);
+ super(message, cause);
}
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java
index 600c60bdb3..6f1db59b1a 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java
@@ -22,9 +22,7 @@ package org.apache.qpid.server.exchange;
import java.util.ArrayList;
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.security.QpidSecurityException;
import org.apache.qpid.server.binding.Binding;
import org.apache.qpid.server.consumer.Consumer;
import org.apache.qpid.server.logging.LogSubject;
@@ -41,7 +39,6 @@ import org.apache.qpid.server.model.UUIDGenerator;
import org.apache.qpid.server.plugin.ExchangeType;
import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.queue.BaseQueue;
-import org.apache.qpid.server.queue.QueueEntry;
import org.apache.qpid.server.store.DurableConfigurationStoreHelper;
import org.apache.qpid.server.store.StorableMessageMetaData;
import org.apache.qpid.server.txn.ServerTransaction;
@@ -114,7 +111,6 @@ public abstract class AbstractExchange implements Exchange
String name,
boolean durable,
boolean autoDelete)
- throws AMQException
{
_virtualHost = host;
_name = name;
@@ -138,7 +134,7 @@ public abstract class AbstractExchange implements Exchange
return _autoDelete;
}
- public void close() throws AMQException
+ public void close() throws QpidSecurityException
{
if(_closed.compareAndSet(false,true))
@@ -458,19 +454,17 @@ public abstract class AbstractExchange implements Exchange
public void postCommit()
{
- for(int i = 0; i < baseQueues.length; i++)
+ try
{
- try
+ for(int i = 0; i < baseQueues.length; i++)
{
baseQueues[i].enqueue(message, postEnqueueAction);
}
- catch (AMQException e)
- {
- // TODO
- throw new RuntimeException(e);
- }
}
- _reference.release();
+ finally
+ {
+ _reference.release();
+ }
}
public void onRollback()
@@ -532,7 +526,7 @@ public abstract class AbstractExchange implements Exchange
@Override
public boolean addBinding(String bindingKey, AMQQueue queue, Map<String, Object> arguments)
- throws AMQSecurityException, AMQInternalException
+ throws QpidSecurityException
{
return makeBinding(null, bindingKey, queue, arguments, false, false);
}
@@ -541,7 +535,7 @@ public abstract class AbstractExchange implements Exchange
public boolean replaceBinding(final UUID id, final String bindingKey,
final AMQQueue queue,
final Map<String, Object> arguments)
- throws AMQSecurityException, AMQInternalException
+ throws QpidSecurityException
{
return makeBinding(id, bindingKey, queue, arguments, false, true);
}
@@ -549,20 +543,20 @@ public abstract class AbstractExchange implements Exchange
@Override
public void restoreBinding(final UUID id, final String bindingKey, final AMQQueue queue,
final Map<String, Object> argumentMap)
- throws AMQSecurityException, AMQInternalException
+ throws QpidSecurityException
{
makeBinding(id, bindingKey,queue, argumentMap,true, false);
}
@Override
- public void removeBinding(final Binding b) throws AMQSecurityException, AMQInternalException
+ public void removeBinding(final Binding b) throws QpidSecurityException
{
removeBinding(b.getBindingKey(), b.getQueue(), b.getArguments());
}
@Override
public Binding removeBinding(String bindingKey, AMQQueue queue, Map<String, Object> arguments)
- throws AMQSecurityException, AMQInternalException
+ throws QpidSecurityException
{
assert queue != null;
@@ -581,7 +575,7 @@ public abstract class AbstractExchange implements Exchange
// Check access
if (!_virtualHost.getSecurityManager().authoriseUnbind(this, bindingKey, queue))
{
- throw new AMQSecurityException("Permission denied: unbinding " + bindingKey);
+ throw new QpidSecurityException("Permission denied: unbinding " + bindingKey);
}
BindingImpl b = _bindingsMap.remove(new BindingImpl(null, bindingKey,queue,arguments));
@@ -628,7 +622,7 @@ public abstract class AbstractExchange implements Exchange
AMQQueue queue,
Map<String, Object> arguments,
boolean restore,
- boolean force) throws AMQSecurityException, AMQInternalException
+ boolean force) throws QpidSecurityException
{
assert queue != null;
@@ -644,7 +638,7 @@ public abstract class AbstractExchange implements Exchange
//Perform ACLs
if (!_virtualHost.getSecurityManager().authoriseBind(AbstractExchange.this, queue, bindingKey))
{
- throw new AMQSecurityException("Permission denied: binding " + bindingKey);
+ throw new QpidSecurityException("Permission denied: binding " + bindingKey);
}
if (id == null)
@@ -696,7 +690,7 @@ public abstract class AbstractExchange implements Exchange
}
- public void onClose(final Exchange exchange) throws AMQSecurityException, AMQInternalException
+ public void onClose(final Exchange exchange) throws QpidSecurityException
{
removeBinding(this);
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchange.java b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchange.java
index 78b9664cd3..d7dfcfbfc5 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchange.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchange.java
@@ -27,9 +27,7 @@ import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
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.security.QpidSecurityException;
import org.apache.qpid.exchange.ExchangeDefaults;
import org.apache.qpid.server.binding.Binding;
import org.apache.qpid.server.consumer.Consumer;
@@ -43,8 +41,6 @@ import org.apache.qpid.server.message.ServerMessage;
import org.apache.qpid.server.model.UUIDGenerator;
import org.apache.qpid.server.plugin.ExchangeType;
import org.apache.qpid.server.queue.AMQQueue;
-import org.apache.qpid.server.queue.BaseQueue;
-import org.apache.qpid.server.queue.QueueEntry;
import org.apache.qpid.server.queue.QueueRegistry;
import org.apache.qpid.server.store.StorableMessageMetaData;
import org.apache.qpid.server.txn.ServerTransaction;
@@ -74,7 +70,7 @@ public class DefaultExchange implements Exchange
VirtualHost host,
String name,
boolean durable,
- boolean autoDelete) throws AMQException
+ boolean autoDelete)
{
_id = id;
_virtualHost = host;
@@ -124,36 +120,36 @@ public class DefaultExchange implements Exchange
@Override
public boolean addBinding(String bindingKey, AMQQueue queue, Map<String, Object> arguments)
- throws AMQSecurityException, AMQInternalException
+ throws QpidSecurityException
{
- throw new AMQSecurityException("Cannot add bindings to the default exchange");
+ throw new QpidSecurityException("Cannot add bindings to the default exchange");
}
@Override
public boolean replaceBinding(UUID id, String bindingKey, AMQQueue queue, Map<String, Object> arguments)
- throws AMQSecurityException, AMQInternalException
+ throws QpidSecurityException
{
- throw new AMQSecurityException("Cannot replace bindings on the default exchange");
+ throw new QpidSecurityException("Cannot replace bindings on the default exchange");
}
@Override
public void restoreBinding(UUID id, String bindingKey, AMQQueue queue, Map<String, Object> argumentMap)
- throws AMQSecurityException, AMQInternalException
+ throws QpidSecurityException
{
_logger.warn("Bindings to the default exchange should not be stored in the configuration store");
}
@Override
- public void removeBinding(Binding b) throws AMQSecurityException, AMQInternalException
+ public void removeBinding(Binding b) throws QpidSecurityException
{
- throw new AMQSecurityException("Cannot remove bindings to the default exchange");
+ throw new QpidSecurityException("Cannot remove bindings to the default exchange");
}
@Override
public Binding removeBinding(String bindingKey, AMQQueue queue, Map<String, Object> arguments)
- throws AMQSecurityException, AMQInternalException
+ throws QpidSecurityException
{
- throw new AMQSecurityException("Cannot remove bindings to the default exchange");
+ throw new QpidSecurityException("Cannot remove bindings to the default exchange");
}
@Override
@@ -201,7 +197,7 @@ public class DefaultExchange implements Exchange
}
@Override
- public void close() throws AMQException
+ public void close()
{
if(_closed.compareAndSet(false,true))
{
@@ -358,11 +354,6 @@ public class DefaultExchange implements Exchange
{
q.enqueue(message, postEnqueueAction);
}
- catch (AMQException e)
- {
- // TODO
- throw new RuntimeException(e);
- }
finally
{
_reference.release();
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeFactory.java b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeFactory.java
index 994f6730e0..a63e1afa3a 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeFactory.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeFactory.java
@@ -22,9 +22,7 @@ package org.apache.qpid.server.exchange;
import org.apache.log4j.Logger;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.AMQSecurityException;
-import org.apache.qpid.AMQUnknownExchangeType;
+import org.apache.qpid.server.security.QpidSecurityException;
import org.apache.qpid.exchange.ExchangeDefaults;
import org.apache.qpid.server.model.UUIDGenerator;
import org.apache.qpid.server.plugin.ExchangeType;
@@ -109,7 +107,7 @@ public class DefaultExchangeFactory implements ExchangeFactory
}
public Exchange createExchange(String exchange, String type, boolean durable, boolean autoDelete)
- throws AMQException
+ throws AMQUnknownExchangeType, QpidSecurityException
{
UUID id = UUIDGenerator.generateExchangeUUID(exchange, _host.getName());
@@ -117,13 +115,13 @@ public class DefaultExchangeFactory implements ExchangeFactory
}
public Exchange createExchange(UUID id, String exchange, String type, boolean durable, boolean autoDelete)
- throws AMQException
+ throws QpidSecurityException, AMQUnknownExchangeType
{
// Check access
if (!_host.getSecurityManager().authoriseCreateExchange(autoDelete, durable, exchange, null, null, null, type))
{
String description = "Permission denied: exchange-name '" + exchange + "'";
- throw new AMQSecurityException(description);
+ throw new QpidSecurityException(description);
}
ExchangeType<? extends Exchange> exchType = _exchangeClassMap.get(type);
@@ -137,7 +135,8 @@ public class DefaultExchangeFactory implements ExchangeFactory
}
@Override
- public Exchange restoreExchange(UUID id, String exchange, String type, boolean autoDelete) throws AMQException
+ public Exchange restoreExchange(UUID id, String exchange, String type, boolean autoDelete)
+ throws AMQUnknownExchangeType, QpidSecurityException
{
return createExchange(id, exchange, type, true, autoDelete);
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeRegistry.java b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeRegistry.java
index b54f995b5e..8d2d04a464 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeRegistry.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeRegistry.java
@@ -21,10 +21,8 @@
package org.apache.qpid.server.exchange;
import org.apache.log4j.Logger;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.AMQSecurityException;
+import org.apache.qpid.server.security.QpidSecurityException;
import org.apache.qpid.exchange.ExchangeDefaults;
-import org.apache.qpid.protocol.AMQConstant;
import org.apache.qpid.server.model.UUIDGenerator;
import org.apache.qpid.server.plugin.ExchangeType;
import org.apache.qpid.server.queue.QueueRegistry;
@@ -60,7 +58,7 @@ public class DefaultExchangeRegistry implements ExchangeRegistry
_queueRegistry = queueRegistry;
}
- public void initialise(ExchangeFactory exchangeFactory) throws AMQException
+ public void initialise(ExchangeFactory exchangeFactory)
{
//create 'standard' exchanges:
new ExchangeInitialiser().initialise(exchangeFactory, this, getDurableConfigurationStore());
@@ -79,7 +77,7 @@ public class DefaultExchangeRegistry implements ExchangeRegistry
return _host.getDurableConfigurationStore();
}
- public void registerExchange(Exchange exchange) throws AMQException
+ public void registerExchange(Exchange exchange)
{
_exchangeMap.put(exchange.getName(), exchange);
synchronized (_listeners)
@@ -102,39 +100,37 @@ public class DefaultExchangeRegistry implements ExchangeRegistry
return _defaultExchange;
}
- public void unregisterExchange(String name, boolean inUse) throws AMQException
+ public boolean unregisterExchange(String name, boolean inUse) throws QpidSecurityException
{
final Exchange exchange = _exchangeMap.get(name);
- if (exchange == null)
+ if (exchange != null)
{
- throw new AMQException(AMQConstant.NOT_FOUND, "Unknown exchange " + name, null);
- }
- if (!_host.getSecurityManager().authoriseDelete(exchange))
- {
- throw new AMQSecurityException();
- }
-
- // TODO: check inUse argument
+ if (!_host.getSecurityManager().authoriseDelete(exchange))
+ {
+ throw new QpidSecurityException();
+ }
- Exchange e = _exchangeMap.remove(name);
- if (e != null)
- {
- e.close();
+ // TODO: check inUse argument
- synchronized (_listeners)
+ Exchange e = _exchangeMap.remove(name);
+ // if it is null then it was removed by another thread at the same time, we can ignore
+ if (e != null)
{
- for(RegistryChangeListener listener : _listeners)
+ e.close();
+
+ synchronized (_listeners)
{
- listener.exchangeUnregistered(exchange);
+ for(RegistryChangeListener listener : _listeners)
+ {
+ listener.exchangeUnregistered(exchange);
+ }
}
- }
+ }
}
- else
- {
- throw new AMQException("Unknown exchange " + name);
- }
+ return exchange != null;
+
}
public Collection<Exchange> getExchanges()
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchange.java b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchange.java
index 2d65c22727..e2db7611eb 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchange.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchange.java
@@ -25,8 +25,8 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.apache.log4j.Logger;
-import org.apache.qpid.AMQInvalidArgumentException;
import org.apache.qpid.server.binding.Binding;
+import org.apache.qpid.server.filter.AMQInvalidArgumentException;
import org.apache.qpid.server.filter.FilterSupport;
import org.apache.qpid.server.filter.Filterable;
import org.apache.qpid.server.filter.MessageFilter;
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchangeType.java b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchangeType.java
index 99c913ad07..3a4f7a9a3b 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchangeType.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchangeType.java
@@ -22,7 +22,6 @@ package org.apache.qpid.server.exchange;
import java.util.UUID;
-import org.apache.qpid.AMQException;
import org.apache.qpid.exchange.ExchangeDefaults;
import org.apache.qpid.server.plugin.ExchangeType;
import org.apache.qpid.server.virtualhost.VirtualHost;
@@ -38,7 +37,7 @@ public class DirectExchangeType implements ExchangeType<DirectExchange>
public DirectExchange newInstance(UUID id, VirtualHost host,
String name,
boolean durable,
- boolean autoDelete) throws AMQException
+ boolean autoDelete)
{
DirectExchange exch = new DirectExchange();
exch.initialise(id, host,name,durable, autoDelete);
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/Exchange.java b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/Exchange.java
index 6d83fdb2a1..38249e6b1f 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/Exchange.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/Exchange.java
@@ -20,9 +20,7 @@
*/
package org.apache.qpid.server.exchange;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.AMQInternalException;
-import org.apache.qpid.AMQSecurityException;
+import org.apache.qpid.server.security.QpidSecurityException;
import org.apache.qpid.server.binding.Binding;
import org.apache.qpid.server.message.MessageDestination;
import org.apache.qpid.server.plugin.ExchangeType;
@@ -35,8 +33,7 @@ import java.util.UUID;
public interface Exchange extends ExchangeReferrer, MessageDestination
{
- void initialise(UUID id, VirtualHost host, String name, boolean durable, boolean autoDelete)
- throws AMQException;
+ void initialise(UUID id, VirtualHost host, String name, boolean durable, boolean autoDelete);
UUID getId();
@@ -70,25 +67,25 @@ public interface Exchange extends ExchangeReferrer, MessageDestination
boolean addBinding(String bindingKey, AMQQueue queue, Map<String, Object> arguments)
- throws AMQSecurityException, AMQInternalException;
+ throws QpidSecurityException;
boolean replaceBinding(UUID id, String bindingKey,
AMQQueue queue,
Map<String, Object> arguments)
- throws AMQSecurityException, AMQInternalException;
+ throws QpidSecurityException;
void restoreBinding(UUID id, String bindingKey, AMQQueue queue,
Map<String, Object> argumentMap)
- throws AMQSecurityException, AMQInternalException;
+ throws QpidSecurityException;
- void removeBinding(Binding b) throws AMQSecurityException, AMQInternalException;
+ void removeBinding(Binding b) throws QpidSecurityException;
Binding removeBinding(String bindingKey, AMQQueue queue, Map<String, Object> arguments)
- throws AMQSecurityException, AMQInternalException;
+ throws QpidSecurityException;
Binding getBinding(String bindingKey, AMQQueue queue, Map<String, Object> arguments);
- void close() throws AMQException;
+ void close() throws QpidSecurityException;
/**
* Determines whether a message would be isBound to a particular queue using a specific routing key and arguments
@@ -96,7 +93,6 @@ public interface Exchange extends ExchangeReferrer, MessageDestination
* @param arguments
* @param queue
* @return
- * @throws AMQException
*/
boolean isBound(String bindingKey, Map<String,Object> arguments, AMQQueue queue);
@@ -106,7 +102,6 @@ public interface Exchange extends ExchangeReferrer, MessageDestination
* @param bindingKey
* @param queue
* @return
- * @throws AMQException
*/
boolean isBound(String bindingKey, AMQQueue queue);
@@ -115,14 +110,12 @@ public interface Exchange extends ExchangeReferrer, MessageDestination
* Determines whether a message is routing to any queue using a specific _routing key
* @param bindingKey
* @return
- * @throws AMQException
*/
boolean isBound(String bindingKey);
/**
* Returns true if this exchange has at least one binding associated with it.
* @return
- * @throws AMQException
*/
boolean hasBindings();
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeFactory.java b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeFactory.java
index f4a3fd940d..06aa3aee2d 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeFactory.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeFactory.java
@@ -20,8 +20,8 @@
*/
package org.apache.qpid.server.exchange;
-import org.apache.qpid.AMQException;
import org.apache.qpid.server.plugin.ExchangeType;
+import org.apache.qpid.server.security.QpidSecurityException;
import java.util.Collection;
import java.util.UUID;
@@ -34,9 +34,12 @@ public interface ExchangeFactory
Collection<ExchangeType<? extends Exchange>> getPublicCreatableTypes();
- Exchange createExchange(String exchange, String type, boolean durable, boolean autoDelete) throws AMQException;
+ Exchange createExchange(String exchange, String type, boolean durable, boolean autoDelete)
+ throws AMQUnknownExchangeType, QpidSecurityException;
- Exchange createExchange(UUID id, String exchange, String type, boolean durable, boolean autoDelete) throws AMQException;
- Exchange restoreExchange(UUID id, String exchange, String type, boolean autoDelete) throws AMQException;
+ Exchange createExchange(UUID id, String exchange, String type, boolean durable, boolean autoDelete) throws AMQUnknownExchangeType,
+ QpidSecurityException;
+ Exchange restoreExchange(UUID id, String exchange, String type, boolean autoDelete)
+ throws AMQUnknownExchangeType, QpidSecurityException;
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeInUseException.java b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeInUseException.java
deleted file mode 100644
index 42b58da07e..0000000000
--- a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeInUseException.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.server.exchange;
-
-import org.apache.qpid.AMQException;
-
-/**
- * ExchangeInUseRegistry indicates that an exchange cannot be unregistered because it is currently being used.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Represents failure to unregister exchange that is in use.
- * </table>
- *
- * @todo Not an AMQP exception as no status code.
- *
- * @todo This exception is not used. However, it is part of the ExchangeRegistry interface, and looks like code is
- * going to need to be added to throw/deal with this. Alternatively ExchangeRegistries may be able to handle the
- * issue internally.
- */
-public class ExchangeInUseException extends AMQException
-{
- public ExchangeInUseException(String exchangeName)
- {
- super("Exchange " + exchangeName + " is currently in use");
- }
-}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeInitialiser.java b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeInitialiser.java
index 6dbc1d54d1..aa3f0de24f 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeInitialiser.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeInitialiser.java
@@ -20,15 +20,15 @@
*/
package org.apache.qpid.server.exchange;
-
-import org.apache.qpid.AMQException;
import org.apache.qpid.server.plugin.ExchangeType;
+import org.apache.qpid.server.security.QpidSecurityException;
import org.apache.qpid.server.store.DurableConfigurationStoreHelper;
import org.apache.qpid.server.store.DurableConfigurationStore;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
public class ExchangeInitialiser
{
- public void initialise(ExchangeFactory factory, ExchangeRegistry registry, DurableConfigurationStore store) throws AMQException
+ public void initialise(ExchangeFactory factory, ExchangeRegistry registry, DurableConfigurationStore store)
{
for (ExchangeType<? extends Exchange> type : factory.getRegisteredTypes())
{
@@ -38,16 +38,29 @@ public class ExchangeInitialiser
}
private void define(ExchangeRegistry r, ExchangeFactory f,
- String name, String type, DurableConfigurationStore store) throws AMQException
+ String name, String type, DurableConfigurationStore store)
{
- if(r.getExchange(name)== null)
+ try
{
- Exchange exchange = f.createExchange(name, type, true, false);
- r.registerExchange(exchange);
- if(exchange.isDurable())
+ if(r.getExchange(name)== null)
{
- DurableConfigurationStoreHelper.createExchange(store, exchange);
+ Exchange exchange = f.createExchange(name, type, true, false);
+ r.registerExchange(exchange);
+ if(exchange.isDurable())
+ {
+ DurableConfigurationStoreHelper.createExchange(store, exchange);
+ }
}
}
+ catch (QpidSecurityException e)
+ {
+ throw new ServerScopedRuntimeException("Security Exception when attempting to initialise exchanges - " +
+ "this is likely a programming error", e);
+ }
+ catch (AMQUnknownExchangeType e)
+ {
+ throw new ServerScopedRuntimeException("Unknown exchange type while attempting to initialise exchanges - " +
+ "this is because necessary jar files are not on the classpath", e);
+ }
}
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeRegistry.java b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeRegistry.java
index 7b4dbf925b..aa66b98a5c 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeRegistry.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeRegistry.java
@@ -20,7 +20,7 @@
*/
package org.apache.qpid.server.exchange;
-import org.apache.qpid.AMQException;
+import org.apache.qpid.server.security.QpidSecurityException;
import java.util.Collection;
import java.util.UUID;
@@ -28,11 +28,11 @@ import java.util.UUID;
public interface ExchangeRegistry
{
- void registerExchange(Exchange exchange) throws AMQException;
+ void registerExchange(Exchange exchange);
Exchange getDefaultExchange();
- void initialise(ExchangeFactory exchangeFactory) throws AMQException;
+ void initialise(ExchangeFactory exchangeFactory);
Exchange getExchange(String exchangeName);
@@ -40,10 +40,8 @@ public interface ExchangeRegistry
* Unregister an exchange
* @param exchange name of the exchange to delete
* @param ifUnused if true, do NOT delete the exchange if it is in use (has queues bound to it)
- * @throws ExchangeInUseException when the exchange cannot be deleted because it is in use
- * @throws AMQException
*/
- void unregisterExchange(String exchange, boolean ifUnused) throws ExchangeInUseException, AMQException;
+ boolean unregisterExchange(String exchange, boolean ifUnused) throws QpidSecurityException;
void clearAndUnregisterMbeans();
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchange.java b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchange.java
index ba60d956fd..fc1a5ea3de 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchange.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchange.java
@@ -27,8 +27,8 @@ import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.log4j.Logger;
-import org.apache.qpid.AMQInvalidArgumentException;
import org.apache.qpid.server.binding.Binding;
+import org.apache.qpid.server.filter.AMQInvalidArgumentException;
import org.apache.qpid.server.filter.FilterSupport;
import org.apache.qpid.server.filter.Filterable;
import org.apache.qpid.server.filter.MessageFilter;
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchangeType.java b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchangeType.java
index 9fc0d1f071..5e1f6784bd 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchangeType.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchangeType.java
@@ -22,7 +22,6 @@ package org.apache.qpid.server.exchange;
import java.util.UUID;
-import org.apache.qpid.AMQException;
import org.apache.qpid.exchange.ExchangeDefaults;
import org.apache.qpid.server.plugin.ExchangeType;
import org.apache.qpid.server.virtualhost.VirtualHost;
@@ -37,7 +36,6 @@ public class FanoutExchangeType implements ExchangeType<FanoutExchange>
public FanoutExchange newInstance(UUID id, VirtualHost host, String name,
boolean durable, boolean autoDelete)
- throws AMQException
{
FanoutExchange exch = new FanoutExchange();
exch.initialise(id, host, name, durable, autoDelete);
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersBinding.java b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersBinding.java
index 276a38e7f8..4780fae84e 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersBinding.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersBinding.java
@@ -22,8 +22,8 @@ package org.apache.qpid.server.exchange;
import org.apache.log4j.Logger;
-import org.apache.qpid.AMQInvalidArgumentException;
import org.apache.qpid.server.binding.Binding;
+import org.apache.qpid.server.filter.AMQInvalidArgumentException;
import org.apache.qpid.server.filter.FilterSupport;
import org.apache.qpid.server.filter.MessageFilter;
import org.apache.qpid.server.message.AMQMessageHeader;
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchangeType.java b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchangeType.java
index 097a7bd5bd..19b830b6b2 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchangeType.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchangeType.java
@@ -22,7 +22,6 @@ package org.apache.qpid.server.exchange;
import java.util.UUID;
-import org.apache.qpid.AMQException;
import org.apache.qpid.exchange.ExchangeDefaults;
import org.apache.qpid.server.plugin.ExchangeType;
import org.apache.qpid.server.virtualhost.VirtualHost;
@@ -36,7 +35,7 @@ public class HeadersExchangeType implements ExchangeType<HeadersExchange>
}
public HeadersExchange newInstance(UUID id, VirtualHost host, String name, boolean durable,
- boolean autoDelete) throws AMQException
+ boolean autoDelete)
{
HeadersExchange exch = new HeadersExchange();
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchange.java b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchange.java
index d86d5cd769..0389638d4f 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchange.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchange.java
@@ -28,12 +28,12 @@ import java.util.HashSet;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.log4j.Logger;
-import org.apache.qpid.AMQInvalidArgumentException;
import org.apache.qpid.server.binding.Binding;
import org.apache.qpid.server.exchange.topic.TopicExchangeResult;
import org.apache.qpid.server.exchange.topic.TopicMatcherResult;
import org.apache.qpid.server.exchange.topic.TopicNormalizer;
import org.apache.qpid.server.exchange.topic.TopicParser;
+import org.apache.qpid.server.filter.AMQInvalidArgumentException;
import org.apache.qpid.server.filter.FilterSupport;
import org.apache.qpid.server.filter.Filterable;
import org.apache.qpid.server.message.InstanceProperties;
@@ -41,6 +41,7 @@ import org.apache.qpid.server.message.ServerMessage;
import org.apache.qpid.server.plugin.ExchangeType;
import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.queue.BaseQueue;
+import org.apache.qpid.server.util.ConnectionScopedRuntimeException;
public class TopicExchange extends AbstractExchange
{
@@ -252,7 +253,8 @@ public class TopicExchange extends AbstractExchange
}
catch (AMQInvalidArgumentException e)
{
- throw new RuntimeException(e);
+ // TODO - this seems incorrect, handling of invalid bindings should be propagated more cleanly
+ throw new ConnectionScopedRuntimeException(e);
}
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchangeType.java b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchangeType.java
index c1f42017bf..f76d556ded 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchangeType.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchangeType.java
@@ -22,7 +22,6 @@ package org.apache.qpid.server.exchange;
import java.util.UUID;
-import org.apache.qpid.AMQException;
import org.apache.qpid.exchange.ExchangeDefaults;
import org.apache.qpid.server.plugin.ExchangeType;
import org.apache.qpid.server.virtualhost.VirtualHost;
@@ -38,7 +37,7 @@ public class TopicExchangeType implements ExchangeType<TopicExchange>
public TopicExchange newInstance(UUID id, VirtualHost host,
String name,
boolean durable,
- boolean autoDelete) throws AMQException
+ boolean autoDelete)
{
TopicExchange exch = new TopicExchange();
exch.initialise(id, host, name, durable, autoDelete);
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/filter/AMQInvalidArgumentException.java b/java/broker-core/src/main/java/org/apache/qpid/server/filter/AMQInvalidArgumentException.java
new file mode 100644
index 0000000000..ec5d68f0a6
--- /dev/null
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/filter/AMQInvalidArgumentException.java
@@ -0,0 +1,43 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.filter;
+
+public class AMQInvalidArgumentException extends Exception
+{
+ public AMQInvalidArgumentException(final Throwable cause)
+ {
+ super(cause);
+ }
+
+ public AMQInvalidArgumentException(final String message, final Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public AMQInvalidArgumentException(final String message)
+ {
+ super(message);
+ }
+
+ public AMQInvalidArgumentException()
+ {
+ }
+}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/filter/FilterManagerFactory.java b/java/broker-core/src/main/java/org/apache/qpid/server/filter/FilterManagerFactory.java
index dc6d5d0123..a159a8506b 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/filter/FilterManagerFactory.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/filter/FilterManagerFactory.java
@@ -22,8 +22,6 @@ package org.apache.qpid.server.filter;
import org.apache.log4j.Logger;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.AMQInvalidArgumentException;
import org.apache.qpid.common.AMQPFilterTypes;
import org.apache.qpid.filter.SelectorParsingException;
import org.apache.qpid.filter.selector.ParseException;
@@ -43,7 +41,7 @@ public class FilterManagerFactory
//TODO move to a common class so it can be referred to from client code.
- public static FilterManager createManager(Map<String,Object> filters) throws AMQException
+ public static FilterManager createManager(Map<String,Object> filters) throws AMQInvalidArgumentException
{
FilterManager manager = null;
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/filter/FilterSupport.java b/java/broker-core/src/main/java/org/apache/qpid/server/filter/FilterSupport.java
index efefec58fd..9870551313 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/filter/FilterSupport.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/filter/FilterSupport.java
@@ -25,7 +25,6 @@ import java.lang.ref.WeakReference;
import java.util.Collections;
import java.util.Map;
import java.util.WeakHashMap;
-import org.apache.qpid.AMQInvalidArgumentException;
import org.apache.qpid.common.AMQPFilterTypes;
import org.apache.qpid.filter.SelectorParsingException;
import org.apache.qpid.filter.selector.ParseException;
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/filter/NoConsumerFilter.java b/java/broker-core/src/main/java/org/apache/qpid/server/filter/NoConsumerFilter.java
deleted file mode 100644
index cf73bfa21f..0000000000
--- a/java/broker-core/src/main/java/org/apache/qpid/server/filter/NoConsumerFilter.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- *
- */
-package org.apache.qpid.server.filter;
-
-import org.apache.log4j.Logger;
-
-import org.apache.qpid.AMQException;
-
-public class NoConsumerFilter implements MessageFilter
-{
- private final static Logger _logger = org.apache.log4j.Logger.getLogger(NoConsumerFilter.class);
-
-
- public NoConsumerFilter() throws AMQException
- {
- _logger.info("Created NoConsumerFilter");
- }
-
- public boolean matches(Filterable message)
- {
- return true;
- }
-
- @Override
- public String toString()
- {
- return "NoConsumer";
- }
-
-}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/message/AbstractServerMessageImpl.java b/java/broker-core/src/main/java/org/apache/qpid/server/message/AbstractServerMessageImpl.java
index a2b7dd10e1..556cfcb266 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/message/AbstractServerMessageImpl.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/message/AbstractServerMessageImpl.java
@@ -22,6 +22,7 @@ package org.apache.qpid.server.message;
import org.apache.qpid.server.store.StorableMessageMetaData;
import org.apache.qpid.server.store.StoredMessage;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
import java.nio.ByteBuffer;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -93,8 +94,8 @@ public abstract class AbstractServerMessageImpl<X extends AbstractServerMessageI
{
if (count < 0)
{
- throw new RuntimeException("Reference count for message id " + debugIdentity()
- + " has gone below 0.");
+ throw new ServerScopedRuntimeException("Reference count for message id " + debugIdentity()
+ + " has gone below 0.");
}
}
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/message/MessageInstance.java b/java/broker-core/src/main/java/org/apache/qpid/server/message/MessageInstance.java
index 49969ce3c1..0bdf83d981 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/message/MessageInstance.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/message/MessageInstance.java
@@ -21,9 +21,7 @@
package org.apache.qpid.server.message;
-import org.apache.qpid.AMQException;
import org.apache.qpid.server.filter.Filterable;
-import org.apache.qpid.server.queue.QueueEntry;
import org.apache.qpid.server.store.TransactionLogResource;
import org.apache.qpid.server.consumer.Consumer;
import org.apache.qpid.server.txn.ServerTransaction;
@@ -65,7 +63,7 @@ public interface MessageInstance<M extends MessageInstance<M,C>, C extends Consu
boolean getDeliveredToConsumer();
- boolean expired() throws AMQException;
+ boolean expired();
boolean acquire(C sub);
@@ -201,7 +199,7 @@ public interface MessageInstance<M extends MessageInstance<M,C>, C extends Consu
void release();
- boolean resend() throws AMQException;
+ boolean resend();
void delete();
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/message/MessageSource.java b/java/broker-core/src/main/java/org/apache/qpid/server/message/MessageSource.java
index 1996c73222..b947bc0ef6 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/message/MessageSource.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/message/MessageSource.java
@@ -20,13 +20,12 @@
*/
package org.apache.qpid.server.message;
-import org.apache.qpid.AMQException;
import org.apache.qpid.server.consumer.Consumer;
import org.apache.qpid.server.consumer.ConsumerTarget;
import org.apache.qpid.server.filter.FilterManager;
import org.apache.qpid.server.protocol.AMQSessionModel;
-import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.security.AuthorizationHolder;
+import org.apache.qpid.server.security.QpidSecurityException;
import org.apache.qpid.server.store.TransactionLogResource;
import java.util.Collection;
@@ -36,7 +35,8 @@ public interface MessageSource<C extends Consumer, S extends MessageSource<C,S>>
{
<T extends ConsumerTarget> C addConsumer(T target, FilterManager filters,
Class<? extends ServerMessage> messageClass,
- String consumerName, EnumSet<Consumer.Option> options) throws AMQException;
+ String consumerName, EnumSet<Consumer.Option> options)
+ throws ExistingExclusiveConsumer, ExistingConsumerPreventsExclusive, QpidSecurityException;
Collection<C> getConsumers();
@@ -68,12 +68,10 @@ public interface MessageSource<C extends Consumer, S extends MessageSource<C,S>>
* <tr><th> Responsibilities <th> Collaborations
* <tr><td> Represent failure to create a consumer, because an exclusive consumer already exists.
* </table>
- *
- * @todo Not an AMQP exception as no status code.
- *
+ * *
* @todo Move to top level, used outside this class.
*/
- static final class ExistingExclusiveConsumer extends AMQException
+ static final class ExistingExclusiveConsumer extends Exception
{
public ExistingExclusiveConsumer()
@@ -90,12 +88,10 @@ public interface MessageSource<C extends Consumer, S extends MessageSource<C,S>>
* <tr><th> Responsibilities <th> Collaborations
* <tr><td> Represent failure to create an exclusive consumer, as a consumer already exists.
* </table>
- *
- * @todo Not an AMQP exception as no status code.
- *
+ * *
* @todo Move to top level, used outside this class.
*/
- static final class ExistingConsumerPreventsExclusive extends AMQException
+ static final class ExistingConsumerPreventsExclusive extends Exception
{
public ExistingConsumerPreventsExclusive()
{
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/message/internal/InternalMessage.java b/java/broker-core/src/main/java/org/apache/qpid/server/message/internal/InternalMessage.java
index f972bd78f6..6375cfb07d 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/message/internal/InternalMessage.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/message/internal/InternalMessage.java
@@ -25,6 +25,7 @@ import org.apache.qpid.server.message.AbstractServerMessageImpl;
import org.apache.qpid.server.store.MessageStore;
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.util.ByteBufferInputStream;
import java.io.ByteArrayOutputStream;
@@ -69,11 +70,12 @@ public class InternalMessage extends AbstractServerMessageImpl<InternalMessage,
}
catch (IOException e)
{
- throw new RuntimeException(e);
+ throw new ConnectionScopedRuntimeException("Unexpected IO Exception in operation in memory", e);
}
catch (ClassNotFoundException e)
{
- throw new RuntimeException(e);
+ throw new ConnectionScopedRuntimeException("Object message contained an object which could not " +
+ "be deserialized", e);
}
}
@@ -142,7 +144,7 @@ public class InternalMessage extends AbstractServerMessageImpl<InternalMessage,
}
catch (IOException e)
{
- throw new RuntimeException(e);
+ throw new ConnectionScopedRuntimeException("Unexpected IO Exception on operation in memory", e);
}
}
@@ -246,7 +248,7 @@ public class InternalMessage extends AbstractServerMessageImpl<InternalMessage,
}
catch (IOException e)
{
- throw new RuntimeException(e);
+ throw new ConnectionScopedRuntimeException("Unexpected IO Exception on operation in memory", e);
}
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/message/internal/InternalMessageMetaData.java b/java/broker-core/src/main/java/org/apache/qpid/server/message/internal/InternalMessageMetaData.java
index d7772657a2..ed16335cf2 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/message/internal/InternalMessageMetaData.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/message/internal/InternalMessageMetaData.java
@@ -21,6 +21,7 @@
package org.apache.qpid.server.message.internal;
import org.apache.qpid.server.store.StorableMessageMetaData;
+import org.apache.qpid.server.util.ConnectionScopedRuntimeException;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -87,7 +88,7 @@ public class InternalMessageMetaData implements StorableMessageMetaData
}
catch (IOException e)
{
- throw new RuntimeException(e);
+ throw new ConnectionScopedRuntimeException("Unexpected IO Exception on in memory operation", e);
}
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/message/internal/InternalMessageMetaDataType.java b/java/broker-core/src/main/java/org/apache/qpid/server/message/internal/InternalMessageMetaDataType.java
index eb90599aef..20e506e634 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/message/internal/InternalMessageMetaDataType.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/message/internal/InternalMessageMetaDataType.java
@@ -23,6 +23,7 @@ package org.apache.qpid.server.message.internal;
import org.apache.qpid.server.message.ServerMessage;
import org.apache.qpid.server.plugin.MessageMetaDataType;
import org.apache.qpid.server.store.StoredMessage;
+import org.apache.qpid.server.util.ConnectionScopedRuntimeException;
import org.apache.qpid.util.ByteBufferInputStream;
import java.io.IOException;
@@ -51,11 +52,11 @@ public class InternalMessageMetaDataType implements MessageMetaDataType<Internal
}
catch (IOException e)
{
- throw new RuntimeException("Cannot decode message header");
+ throw new ConnectionScopedRuntimeException("Unexpected IO Exception on operation in memory", e);
}
catch (ClassNotFoundException e)
{
- throw new RuntimeException(e);
+ throw new ConnectionScopedRuntimeException("Unexpected exception when reading meta data, check classpath",e);
}
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractAdapter.java b/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractAdapter.java
index 7cc88f8743..cc669538d8 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractAdapter.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractAdapter.java
@@ -131,7 +131,7 @@ public abstract class AbstractAdapter implements ConfiguredObject
}
else
{
- return (State)_taskExecutor.submitAndWait(new ChangeStateTask(this, currentState, desiredState));
+ return _taskExecutor.submitAndWait(new ChangeStateTask(this, currentState, desiredState));
}
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AmqpPortAdapter.java b/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AmqpPortAdapter.java
index c255ce2f4a..42a234579b 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AmqpPortAdapter.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AmqpPortAdapter.java
@@ -47,6 +47,7 @@ import org.apache.qpid.server.plugin.TransportProviderFactory;
import org.apache.qpid.server.protocol.AmqpProtocolVersion;
import org.apache.qpid.server.transport.AcceptingTransport;
import org.apache.qpid.server.transport.TransportProvider;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
import org.apache.qpid.transport.network.security.ssl.QpidMultipleTrustManager;
public class AmqpPortAdapter extends PortAdapter
@@ -187,7 +188,7 @@ public class AmqpPortAdapter extends PortAdapter
}
catch (GeneralSecurityException e)
{
- throw new RuntimeException("Unable to create SSLContext for key or trust store", e);
+ throw new ServerScopedRuntimeException("Unable to create SSLContext for key or trust store", e);
}
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AuthenticationProviderAdapter.java b/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AuthenticationProviderAdapter.java
index 033429980f..0fcdb779c1 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AuthenticationProviderAdapter.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AuthenticationProviderAdapter.java
@@ -554,8 +554,9 @@ public abstract class AuthenticationProviderAdapter<T extends AuthenticationMana
}
else
{
- //TODO? Silly interface on the PrincipalDatabase at fault
- throw new RuntimeException("Failed to create user");
+ LOGGER.info("Failed to create user " + username + ". User already exists?");
+ return null;
+
}
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BindingAdapter.java b/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BindingAdapter.java
index 92b8f55f23..88475809c9 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BindingAdapter.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BindingAdapter.java
@@ -26,8 +26,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-import org.apache.qpid.AMQInternalException;
-import org.apache.qpid.AMQSecurityException;
+import org.apache.qpid.server.security.QpidSecurityException;
import org.apache.qpid.server.model.Binding;
import org.apache.qpid.server.model.ConfiguredObject;
import org.apache.qpid.server.model.Exchange;
@@ -144,14 +143,10 @@ final class BindingAdapter extends AbstractAdapter implements Binding
{
_exchange.getExchange().removeBinding(_binding);
}
- catch(AMQSecurityException e)
+ catch(QpidSecurityException e)
{
throw new AccessControlException(e.getMessage());
}
- catch(AMQInternalException e)
- {
- throw new IllegalStateException(e);
- }
}
@Override
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java b/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java
index dd5fc67b48..dda23f1cfc 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java
@@ -30,7 +30,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import org.apache.qpid.AMQException;
import org.apache.qpid.protocol.AMQConstant;
import org.apache.qpid.server.model.ConfiguredObject;
import org.apache.qpid.server.model.Connection;
@@ -109,14 +108,7 @@ final class ConnectionAdapter extends AbstractAdapter implements Connection
public void delete()
{
- try
- {
- _connection.close(AMQConstant.CONNECTION_FORCED, "Connection closed by external action");
- }
- catch(AMQException e)
- {
- throw new IllegalStateException(e);
- }
+ _connection.close(AMQConstant.CONNECTION_FORCED, "Connection closed by external action");
}
public String getName()
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ExchangeAdapter.java b/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ExchangeAdapter.java
index 0963f01522..f7ecbd323a 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ExchangeAdapter.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ExchangeAdapter.java
@@ -27,9 +27,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.AMQInternalException;
-import org.apache.qpid.AMQSecurityException;
+import org.apache.qpid.server.security.QpidSecurityException;
import org.apache.qpid.server.binding.Binding;
import org.apache.qpid.server.model.ConfiguredObject;
import org.apache.qpid.server.model.ConfiguredObjectFinder;
@@ -41,6 +39,7 @@ import org.apache.qpid.server.model.State;
import org.apache.qpid.server.model.Statistics;
import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.util.MapValueConverter;
+import org.apache.qpid.server.virtualhost.ExchangeIsAlternateException;
import org.apache.qpid.server.virtualhost.RequiredExchangeException;
final class ExchangeAdapter extends AbstractAdapter implements Exchange, org.apache.qpid.server.exchange.Exchange.BindingListener
@@ -147,14 +146,10 @@ final class ExchangeAdapter extends AbstractAdapter implements Exchange, org.apa
return binding == null ? null : _bindingAdapters.get(binding);
}
}
- catch(AMQSecurityException e)
+ catch(QpidSecurityException e)
{
throw new AccessControlException(e.toString());
}
- catch(AMQInternalException e)
- {
- throw new IllegalStateException(e);
- }
}
public void delete()
@@ -167,10 +162,14 @@ final class ExchangeAdapter extends AbstractAdapter implements Exchange, org.apa
{
throw new UnsupportedOperationException("'" + getName() + "' is a reserved exchange and can't be deleted");
}
- catch(AMQException e)
+ catch(ExchangeIsAlternateException e)
{
throw new IllegalStateException(e);
}
+ catch (QpidSecurityException e)
+ {
+ throw new AccessControlException(e.toString());
+ }
}
public String getName()
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProvider.java b/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProvider.java
index 39f0017fc3..ea1f735c15 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProvider.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProvider.java
@@ -246,7 +246,7 @@ public class FileSystemPreferencesProvider extends AbstractAdapter implements Pr
_store.open();
return true;
}
- catch (Exception e)
+ catch (RuntimeException e)
{
_state.compareAndSet(State.ACTIVE, State.ERRORED);
Broker broker = getAuthenticationProvider().getParent(Broker.class);
@@ -256,7 +256,7 @@ public class FileSystemPreferencesProvider extends AbstractAdapter implements Pr
}
else
{
- throw new RuntimeException(e);
+ throw e;
}
}
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/KeyStoreAdapter.java b/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/KeyStoreAdapter.java
index 1101232c96..27ecb9ca75 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/KeyStoreAdapter.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/KeyStoreAdapter.java
@@ -45,6 +45,7 @@ import org.apache.qpid.server.model.Port;
import org.apache.qpid.server.model.State;
import org.apache.qpid.server.security.access.Operation;
import org.apache.qpid.server.util.MapValueConverter;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
import org.apache.qpid.transport.network.security.ssl.QpidClientX509KeyManager;
import org.apache.qpid.transport.network.security.ssl.SSLUtil;
@@ -195,7 +196,7 @@ public class KeyStoreAdapter extends AbstractKeyStoreAdapter implements KeyStore
catch (KeyStoreException e)
{
// key store should be initialized above
- throw new RuntimeException("Key store has not been initialized", e);
+ throw new ServerScopedRuntimeException("Key store has not been initialized", e);
}
if (cert == null)
{
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/QueueAdapter.java b/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/QueueAdapter.java
index e2c29ede51..733b6cecc2 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/QueueAdapter.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/QueueAdapter.java
@@ -28,8 +28,6 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.AMQStoreException;
import org.apache.qpid.server.binding.Binding;
import org.apache.qpid.server.configuration.IllegalConfigurationException;
import org.apache.qpid.server.message.MessageSource;
@@ -45,6 +43,7 @@ import org.apache.qpid.server.model.Statistics;
import org.apache.qpid.server.protocol.AMQConnectionModel;
import org.apache.qpid.server.protocol.AMQSessionModel;
import org.apache.qpid.server.queue.*;
+import org.apache.qpid.server.security.QpidSecurityException;
import org.apache.qpid.server.store.DurableConfigurationStoreHelper;
import org.apache.qpid.server.consumer.Consumer;
import org.apache.qpid.server.util.MapValueConverter;
@@ -174,9 +173,9 @@ final class QueueAdapter<Q extends AMQQueue<?,Q,?>> extends AbstractAdapter impl
{
_queue.getVirtualHost().removeQueue(_queue);
}
- catch(AMQException e)
+ catch (QpidSecurityException e)
{
- throw new IllegalStateException(e);
+ throw new AccessControlException(e.toString());
}
}
@@ -338,15 +337,8 @@ final class QueueAdapter<Q extends AMQQueue<?,Q,?>> extends AbstractAdapter impl
{
if (_queue.isDurable())
{
- try
- {
- DurableConfigurationStoreHelper.updateQueue(_queue.getVirtualHost().getDurableConfigurationStore(),
- _queue);
- }
- catch (AMQStoreException e)
- {
- throw new IllegalStateException(e);
- }
+ DurableConfigurationStoreHelper.updateQueue(_queue.getVirtualHost().getDurableConfigurationStore(),
+ _queue);
}
}
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java b/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java
index c43dc34d2f..17ce69da4a 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java
@@ -40,7 +40,7 @@ import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.configuration.SystemConfiguration;
import org.apache.log4j.Logger;
-import org.apache.qpid.AMQException;
+import org.apache.qpid.server.exchange.AMQUnknownExchangeType;
import org.apache.qpid.server.configuration.IllegalConfigurationException;
import org.apache.qpid.server.configuration.VirtualHostConfiguration;
import org.apache.qpid.server.configuration.XmlConfigurationUtilities.MyConfiguration;
@@ -66,6 +66,7 @@ import org.apache.qpid.server.plugin.ExchangeType;
import org.apache.qpid.server.protocol.AMQConnectionModel;
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.access.Operation;
import org.apache.qpid.server.security.auth.AuthenticatedPrincipal;
@@ -75,12 +76,13 @@ import org.apache.qpid.server.txn.LocalTransaction;
import org.apache.qpid.server.txn.ServerTransaction;
import org.apache.qpid.server.util.MapValueConverter;
import org.apache.qpid.server.plugin.VirtualHostFactory;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
import org.apache.qpid.server.virtualhost.ExchangeExistsException;
import org.apache.qpid.server.virtualhost.ReservedExchangeNameException;
import org.apache.qpid.server.virtualhost.UnknownExchangeException;
import org.apache.qpid.server.virtualhost.VirtualHostListener;
import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
-import org.apache.qpid.server.virtualhost.plugins.QueueExistsException;
+import org.apache.qpid.server.virtualhost.QueueExistsException;
public final class VirtualHostAdapter extends AbstractAdapter implements VirtualHost, VirtualHostListener
{
@@ -374,10 +376,14 @@ public final class VirtualHostAdapter extends AbstractAdapter implements Virtual
{
throw new IllegalArgumentException("Alternate Exchange with name '" + e.getExchangeName() + "' does not exist");
}
- catch(AMQException e)
+ catch(AMQUnknownExchangeType e)
{
throw new IllegalArgumentException(e);
}
+ catch (QpidSecurityException e)
+ {
+ throw new AccessControlException(e.toString());
+ }
}
public Queue createQueue(Map<String, Object> attributes)
@@ -467,9 +473,9 @@ public final class VirtualHostAdapter extends AbstractAdapter implements Virtual
{
throw new IllegalArgumentException("Queue with name "+name+" already exists");
}
- catch(AMQException e)
+ catch (QpidSecurityException e)
{
- throw new IllegalArgumentException(e);
+ throw new AccessControlException(e.toString());
}
}
@@ -791,14 +797,7 @@ public final class VirtualHostAdapter extends AbstractAdapter implements Virtual
{
public void postCommit()
{
- try
- {
- toQueue.enqueue(message, null);
- }
- catch(AMQException e)
- {
- throw new RuntimeException(e);
- }
+ toQueue.enqueue(message, null);
}
public void onRollback()
@@ -820,14 +819,7 @@ public final class VirtualHostAdapter extends AbstractAdapter implements Virtual
public void postCommit()
{
- try
- {
- toQueue.enqueue(message, null);
- }
- catch (AMQException e)
- {
- throw new RuntimeException(e);
- }
+ toQueue.enqueue(message, null);
}
public void onRollback()
@@ -1139,9 +1131,9 @@ public final class VirtualHostAdapter extends AbstractAdapter implements Virtual
this);
}
}
- catch (Exception e)
+ catch (ConfigurationException e)
{
- throw new RuntimeException("Failed to create virtual host " + virtualHostName, e);
+ throw new ServerScopedRuntimeException("Failed to create virtual host " + virtualHostName, e);
}
virtualHostRegistry.registerVirtualHost(_virtualHost);
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ExchangeType.java b/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ExchangeType.java
index 423b76ab8e..910dfbf33d 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ExchangeType.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ExchangeType.java
@@ -22,7 +22,6 @@ package org.apache.qpid.server.plugin;
import java.util.UUID;
-import org.apache.qpid.AMQException;
import org.apache.qpid.server.exchange.Exchange;
import org.apache.qpid.server.virtualhost.VirtualHost;
@@ -31,7 +30,7 @@ public interface ExchangeType<T extends Exchange> extends Pluggable
public String getType();
public T newInstance(UUID id, VirtualHost host, String name,
- boolean durable, boolean autoDelete) throws AMQException;
+ boolean durable, boolean autoDelete);
public String getDefaultExchangeName();
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/plugin/QpidServiceLoader.java b/java/broker-core/src/main/java/org/apache/qpid/server/plugin/QpidServiceLoader.java
index 148a306b27..6920d5a879 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/plugin/QpidServiceLoader.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/plugin/QpidServiceLoader.java
@@ -24,6 +24,7 @@ import java.util.List;
import java.util.ServiceLoader;
import org.apache.log4j.Logger;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
/**
* Simple facade over a {@link ServiceLoader} to instantiate all configured implementations of an interface.
@@ -59,7 +60,7 @@ public class QpidServiceLoader<C extends Pluggable>
if(atLeastOne && serviceImplementations.isEmpty())
{
- throw new RuntimeException("At least one implementation of " + clazz + " expected");
+ throw new ServerScopedRuntimeException("At least one implementation of " + clazz + " expected");
}
if(_logger.isDebugEnabled())
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/plugin/VirtualHostFactory.java b/java/broker-core/src/main/java/org/apache/qpid/server/plugin/VirtualHostFactory.java
index 9549b70c83..a073c89a1b 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/plugin/VirtualHostFactory.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/plugin/VirtualHostFactory.java
@@ -41,7 +41,7 @@ public interface VirtualHostFactory extends Pluggable
StatisticsGatherer brokerStatisticsGatherer,
SecurityManager parentSecurityManager,
VirtualHostConfiguration hostConfig,
- org.apache.qpid.server.model.VirtualHost virtualHost) throws Exception;
+ org.apache.qpid.server.model.VirtualHost virtualHost);
void validateAttributes(Map<String, Object> attributes);
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/protocol/AMQConnectionModel.java b/java/broker-core/src/main/java/org/apache/qpid/server/protocol/AMQConnectionModel.java
index 180653af0e..bc272f13dc 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/protocol/AMQConnectionModel.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/protocol/AMQConnectionModel.java
@@ -20,7 +20,6 @@
*/
package org.apache.qpid.server.protocol;
-import org.apache.qpid.AMQException;
import org.apache.qpid.protocol.AMQConstant;
import org.apache.qpid.server.logging.LogSubject;
import org.apache.qpid.server.model.Port;
@@ -37,9 +36,8 @@ public interface AMQConnectionModel extends StatisticsGatherer
*
* @param cause
* @param message
- * @throws org.apache.qpid.AMQException
*/
- public void close(AMQConstant cause, String message) throws AMQException;
+ public void close(AMQConstant cause, String message);
public void block();
@@ -51,9 +49,8 @@ public interface AMQConnectionModel extends StatisticsGatherer
* @param session
* @param cause
* @param message
- * @throws org.apache.qpid.AMQException
*/
- public void closeSession(AMQSessionModel session, AMQConstant cause, String message) throws AMQException;
+ public void closeSession(AMQSessionModel session, AMQConstant cause, String message);
public long getConnectionId();
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/protocol/AMQSessionModel.java b/java/broker-core/src/main/java/org/apache/qpid/server/protocol/AMQSessionModel.java
index 28fadd4162..520489ab1f 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/protocol/AMQSessionModel.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/protocol/AMQSessionModel.java
@@ -23,7 +23,6 @@ package org.apache.qpid.server.protocol;
import java.util.UUID;
import java.util.concurrent.ConcurrentSkipListSet;
-import org.apache.qpid.AMQException;
import org.apache.qpid.protocol.AMQConstant;
import org.apache.qpid.server.logging.LogSubject;
import org.apache.qpid.server.queue.AMQQueue;
@@ -41,9 +40,9 @@ public interface AMQSessionModel extends Comparable<AMQSessionModel>
public String getClientID();
- public void close() throws AMQException;
+ public void close();
- public void close(AMQConstant cause, String message) throws AMQException;
+ public void close(AMQConstant cause, String message);
public LogSubject getLogSubject();
@@ -62,7 +61,7 @@ public interface AMQSessionModel extends Comparable<AMQSessionModel>
* @param idleWarn time in milliseconds before alerting on idle transaction
* @param idleClose time in milliseconds before closing connection with idle transaction
*/
- public void checkTransactionStatus(long openWarn, long openClose, long idleWarn, long idleClose) throws AMQException;
+ public void checkTransactionStatus(long openWarn, long openClose, long idleWarn, long idleClose);
void block(AMQQueue queue);
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueue.java b/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueue.java
index 76477a0a9b..237f2cd8aa 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueue.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueue.java
@@ -20,7 +20,6 @@
*/
package org.apache.qpid.server.queue;
-import org.apache.qpid.AMQException;
import org.apache.qpid.server.binding.Binding;
import org.apache.qpid.server.configuration.QueueConfiguration;
import org.apache.qpid.server.exchange.Exchange;
@@ -30,6 +29,7 @@ import org.apache.qpid.server.message.MessageDestination;
import org.apache.qpid.server.message.MessageSource;
import org.apache.qpid.server.protocol.CapacityChecker;
import org.apache.qpid.server.consumer.Consumer;
+import org.apache.qpid.server.security.QpidSecurityException;
import org.apache.qpid.server.util.Action;
import org.apache.qpid.server.virtualhost.VirtualHost;
@@ -94,7 +94,7 @@ public interface AMQQueue<E extends QueueEntry<E,Q,C>, Q extends AMQQueue<E,Q,C>
boolean isDeleted();
- int delete() throws AMQException;
+ int delete() throws QpidSecurityException;
void requeue(E entry);
@@ -102,7 +102,7 @@ public interface AMQQueue<E extends QueueEntry<E,Q,C>, Q extends AMQQueue<E,Q,C>
void decrementUnackedMsgCount(E queueEntry);
- boolean resend(final E entry, final C consumer) throws AMQException;
+ boolean resend(final E entry, final C consumer);
void addQueueDeleteTask(Action<AMQQueue> task);
void removeQueueDeleteTask(Action<AMQQueue> task);
@@ -169,13 +169,12 @@ public interface AMQQueue<E extends QueueEntry<E,Q,C>, Q extends AMQQueue<E,Q,C>
void deleteMessageFromTop();
- long clearQueue() throws AMQException;
+ long clearQueue() throws QpidSecurityException;
/**
* Checks the status of messages on the queue, purging expired ones, firing age related alerts etc.
- * @throws AMQException
*/
- void checkMessageStatus() throws AMQException;
+ void checkMessageStatus();
Set<NotificationCheck> getNotificationChecks();
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java b/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java
index 4e0a9048e1..409c528a4b 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java
@@ -25,8 +25,8 @@ import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.AMQSecurityException;
+import org.apache.qpid.server.exchange.AMQUnknownExchangeType;
+import org.apache.qpid.server.security.QpidSecurityException;
import org.apache.qpid.exchange.ExchangeDefaults;
import org.apache.qpid.server.configuration.BrokerProperties;
import org.apache.qpid.server.configuration.QueueConfiguration;
@@ -35,8 +35,13 @@ import org.apache.qpid.server.exchange.Exchange;
import org.apache.qpid.server.model.Queue;
import org.apache.qpid.server.model.UUIDGenerator;
import org.apache.qpid.server.store.DurableConfigurationStoreHelper;
+import org.apache.qpid.server.util.ConnectionScopedRuntimeException;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
import org.apache.qpid.server.virtualhost.ExchangeExistsException;
+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.QueueExistsException;
public class AMQQueueFactory implements QueueFactory
{
@@ -183,7 +188,7 @@ public class AMQQueueFactory implements QueueFactory
boolean autoDelete,
boolean exclusive,
boolean deleteOnNoConsumer,
- Map<String, Object> arguments) throws AMQSecurityException, AMQException
+ Map<String, Object> arguments) throws QpidSecurityException
{
return createOrRestoreQueue(id, queueName, true, owner, autoDelete, exclusive, deleteOnNoConsumer, arguments, false);
@@ -201,7 +206,7 @@ public class AMQQueueFactory implements QueueFactory
boolean autoDelete,
boolean exclusive,
boolean deleteOnNoConsumer,
- Map<String, Object> arguments) throws AMQSecurityException, AMQException
+ Map<String, Object> arguments) throws QpidSecurityException
{
return createOrRestoreQueue(id, queueName, durable, owner, autoDelete, exclusive, deleteOnNoConsumer, arguments, true);
}
@@ -214,7 +219,7 @@ public class AMQQueueFactory implements QueueFactory
boolean exclusive,
boolean deleteOnNoConsumer,
Map<String, Object> arguments,
- boolean createInStore) throws AMQSecurityException, AMQException
+ boolean createInStore) throws QpidSecurityException
{
if (id == null)
{
@@ -339,6 +344,18 @@ public class AMQQueueFactory implements QueueFactory
// We're ok if the exchange already exists
dlExchange = e.getExistingExchange();
}
+ catch (ReservedExchangeNameException e)
+ {
+ throw new ConnectionScopedRuntimeException("Attempt to create an alternate exchange for a queue failed",e);
+ }
+ catch (AMQUnknownExchangeType e)
+ {
+ throw new ConnectionScopedRuntimeException("Attempt to create an alternate exchange for a queue failed",e);
+ }
+ catch (UnknownExchangeException e)
+ {
+ throw new ConnectionScopedRuntimeException("Attempt to create an alternate exchange for a queue failed",e);
+ }
AMQQueue dlQueue = null;
@@ -353,8 +370,19 @@ public class AMQQueueFactory implements QueueFactory
args.put(Queue.CREATE_DLQ_ON_CREATION, false);
args.put(Queue.MAXIMUM_DELIVERY_ATTEMPTS, 0);
- dlQueue = _virtualHost.createQueue(UUIDGenerator.generateQueueUUID(dlQueueName, _virtualHost.getName()), dlQueueName, true, owner, false, exclusive,
- false, args);
+ try
+ {
+ dlQueue = _virtualHost.createQueue(UUIDGenerator.generateQueueUUID(dlQueueName, _virtualHost.getName()), dlQueueName, true, owner, false, exclusive,
+ false, args);
+ }
+ catch (QueueExistsException e)
+ {
+ throw new ServerScopedRuntimeException("Attempt to create a queue failed because the " +
+ "queue already exists, however this occurred within " +
+ "a block where the queue existence had previously been " +
+ "checked, and no queue creation should have been " +
+ "possible from another thread", e);
+ }
}
}
@@ -391,7 +419,7 @@ public class AMQQueueFactory implements QueueFactory
return q;
}
- public AMQQueue createAMQQueueImpl(QueueConfiguration config) throws AMQException
+ public AMQQueue createAMQQueueImpl(QueueConfiguration config) throws QpidSecurityException
{
String queueName = config.getName();
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/queue/BaseQueue.java b/java/broker-core/src/main/java/org/apache/qpid/server/queue/BaseQueue.java
index 31c54dcdd2..4158e51d2f 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/queue/BaseQueue.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/queue/BaseQueue.java
@@ -21,7 +21,6 @@
package org.apache.qpid.server.queue;
-import org.apache.qpid.AMQException;
import org.apache.qpid.server.consumer.Consumer;
import org.apache.qpid.server.message.MessageInstance;
import org.apache.qpid.server.message.ServerMessage;
@@ -30,7 +29,7 @@ import org.apache.qpid.server.util.Action;
public interface BaseQueue<C extends Consumer> extends TransactionLogResource
{
- void enqueue(ServerMessage message, Action<? super MessageInstance<?,C>> action) throws AMQException;
+ void enqueue(ServerMessage message, Action<? super MessageInstance<?,C>> action);
boolean isDurable();
boolean isDeleted();
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumer.java b/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumer.java
index 5c891797f5..45dc556732 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumer.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumer.java
@@ -21,7 +21,6 @@
package org.apache.qpid.server.queue;
import org.apache.log4j.Logger;
-import org.apache.qpid.AMQException;
import org.apache.qpid.server.filter.FilterManager;
import org.apache.qpid.server.logging.LogActor;
import org.apache.qpid.server.logging.LogSubject;
@@ -41,7 +40,6 @@ import java.text.MessageFormat;
import java.util.EnumMap;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
@@ -149,15 +147,7 @@ class QueueConsumer<T extends ConsumerTarget, E extends QueueEntryImpl<E,Q,L>, Q
if(newState == ConsumerTarget.State.CLOSED && oldState != newState && !_closed.get())
{
- try
- {
- close();
- }
- catch (AMQException e)
- {
- _logger.error("Unable to remove to remove consumer", e);
- throw new RuntimeException(e);
- }
+ close();
}
final StateChangeListener<? super QueueConsumer<T,E,Q,L>, State> stateListener = getStateListener();
if(stateListener != null)
@@ -202,7 +192,7 @@ class QueueConsumer<T extends ConsumerTarget, E extends QueueEntryImpl<E,Q,L>, Q
}
@Override
- public void close() throws AMQException
+ public void close()
{
if(_closed.compareAndSet(false,true))
{
@@ -241,7 +231,7 @@ class QueueConsumer<T extends ConsumerTarget, E extends QueueEntryImpl<E,Q,L>, Q
_target.restoreCredit(queueEntry.getMessage());
}
- void queueEmpty() throws AMQException
+ void queueEmpty()
{
_target.queueEmpty();
}
@@ -295,12 +285,12 @@ class QueueConsumer<T extends ConsumerTarget, E extends QueueEntryImpl<E,Q,L>, Q
@Override
- public final void flush() throws AMQException
+ public final void flush()
{
getQueue().flushConsumer(this);
}
- boolean resend(final E entry) throws AMQException
+ boolean resend(final E entry)
{
return getQueue().resend(entry, this);
}
@@ -460,14 +450,10 @@ class QueueConsumer<T extends ConsumerTarget, E extends QueueEntryImpl<E,Q,L>, Q
return _deliveredCount.longValue();
}
- final void send(final E entry, final boolean batch) throws AMQException
+ final void send(final E entry, final boolean batch)
{
_deliveredCount.incrementAndGet();
ServerMessage message = entry.getMessage();
- if(message == null)
- {
- throw new AMQException("message was null!");
- }
_deliveredBytes.addAndGet(message.getSize());
_target.send(entry, batch);
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueEntryImpl.java b/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueEntryImpl.java
index ae5c560db0..1f09fe3fb9 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueEntryImpl.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueEntryImpl.java
@@ -22,7 +22,6 @@ package org.apache.qpid.server.queue;
import org.apache.log4j.Logger;
-import org.apache.qpid.AMQException;
import org.apache.qpid.server.exchange.Exchange;
import org.apache.qpid.server.filter.Filterable;
import org.apache.qpid.server.message.InstanceProperties;
@@ -158,7 +157,7 @@ public abstract class QueueEntryImpl<E extends QueueEntryImpl<E,Q,L>, Q extends
return _deliveredToConsumer;
}
- public boolean expired() throws AMQException
+ public boolean expired()
{
ServerMessage message = getMessage();
if(message != null)
@@ -493,7 +492,7 @@ public abstract class QueueEntryImpl<E extends QueueEntryImpl<E,Q,L>, Q extends
}
@Override
- public boolean resend() throws AMQException
+ public boolean resend()
{
QueueConsumer<?,E,Q,L> sub = getDeliveredConsumer();
if(sub != null)
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueFactory.java b/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueFactory.java
index 3e4e1df5a2..8c0386c7b4 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueFactory.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueFactory.java
@@ -22,8 +22,7 @@ package org.apache.qpid.server.queue;
import java.util.Map;
import java.util.UUID;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.AMQSecurityException;
+import org.apache.qpid.server.security.QpidSecurityException;
public interface QueueFactory
{
@@ -34,7 +33,7 @@ public interface QueueFactory
boolean autoDelete,
boolean exclusive,
boolean deleteOnNoConsumer,
- Map<String, Object> arguments) throws AMQSecurityException, AMQException;
+ Map<String, Object> arguments) throws QpidSecurityException;
AMQQueue restoreQueue(UUID id,
String queueName,
@@ -42,6 +41,6 @@ public interface QueueFactory
boolean autoDelete,
boolean exclusive,
boolean deleteOnNoConsumer,
- Map<String, Object> arguments) throws AMQSecurityException, AMQException;
+ Map<String, Object> arguments) throws QpidSecurityException;
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueRunner.java b/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueRunner.java
index 005d9b66b3..317e184dae 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueRunner.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueRunner.java
@@ -26,8 +26,8 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.log4j.Logger;
-import org.apache.qpid.AMQException;
import org.apache.qpid.server.logging.actors.CurrentActor;
+import org.apache.qpid.server.util.ConnectionScopedRuntimeException;
import org.apache.qpid.transport.TransportException;
/**
@@ -70,9 +70,17 @@ public class QueueRunner implements Runnable
runAgain = _queue.processQueue(this);
}
- catch (final AMQException e)
+ catch (final ConnectionScopedRuntimeException e)
{
- _logger.error("Exception during asynchronous delivery by " + toString(), e);
+ final String errorMessage = "Problem during asynchronous delivery by " + toString();
+ if(_logger.isDebugEnabled())
+ {
+ _logger.debug(errorMessage, e);
+ }
+ else
+ {
+ _logger.info(errorMessage + ' ' + e.getMessage());
+ }
}
catch (final TransportException transe)
{
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java b/java/broker-core/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java
index 4450a3ed0c..b2408f6dfa 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java
@@ -28,8 +28,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.log4j.Logger;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.AMQSecurityException;
+import org.apache.qpid.server.security.QpidSecurityException;
import org.apache.qpid.pool.ReferenceCountingExecutorService;
import org.apache.qpid.server.binding.Binding;
import org.apache.qpid.server.configuration.BrokerProperties;
@@ -56,6 +55,7 @@ import org.apache.qpid.server.txn.AutoCommitTransaction;
import org.apache.qpid.server.txn.LocalTransaction;
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.util.StateChangeListener;
import org.apache.qpid.server.virtualhost.VirtualHost;
@@ -381,13 +381,13 @@ abstract class SimpleAMQQueue<E extends QueueEntryImpl<E,Q,L>, Q extends SimpleA
final FilterManager filters,
final Class<? extends ServerMessage> messageClass,
final String consumerName,
- EnumSet<Consumer.Option> optionSet) throws AMQException
+ EnumSet<Consumer.Option> optionSet) throws ExistingExclusiveConsumer, ExistingConsumerPreventsExclusive, QpidSecurityException
{
// Access control
if (!getVirtualHost().getSecurityManager().authoriseConsume(this))
{
- throw new AMQSecurityException("Permission denied");
+ throw new QpidSecurityException("Permission denied");
}
@@ -459,7 +459,7 @@ abstract class SimpleAMQQueue<E extends QueueEntryImpl<E,Q,L>, Q extends SimpleA
}
- synchronized void unregisterConsumer(final QueueConsumer<?,E,Q,L> consumer) throws AMQException
+ synchronized void unregisterConsumer(final QueueConsumer<?,E,Q,L> consumer)
{
if (consumer == null)
{
@@ -502,7 +502,14 @@ abstract class SimpleAMQQueue<E extends QueueEntryImpl<E,Q,L>, Q extends SimpleA
_logger.info("Auto-deleting queue:" + this);
}
- getVirtualHost().removeQueue(this);
+ try
+ {
+ getVirtualHost().removeQueue(this);
+ }
+ catch (QpidSecurityException e)
+ {
+ throw new ConnectionScopedRuntimeException("Auto delete queue unable to delete itself", e);
+ }
// we need to manually fire the event to the removed consumer (which was the last one left for this
// queue. This is because the delete method uses the consumer set which has just been cleared
@@ -614,7 +621,7 @@ abstract class SimpleAMQQueue<E extends QueueEntryImpl<E,Q,L>, Q extends SimpleA
// ------ Enqueue / Dequeue
- public void enqueue(ServerMessage message, Action<? super MessageInstance<?, QueueConsumer<?,E,Q,L>>> action) throws AMQException
+ public void enqueue(ServerMessage message, Action<? super MessageInstance<?, QueueConsumer<?,E,Q,L>>> action)
{
incrementQueueCount();
incrementQueueSize(message);
@@ -703,7 +710,6 @@ abstract class SimpleAMQQueue<E extends QueueEntryImpl<E,Q,L>, Q extends SimpleA
}
private void deliverToConsumer(final QueueConsumer<?,E,Q,L> sub, final E entry)
- throws AMQException
{
if(sub.trySendLock())
@@ -793,7 +799,6 @@ abstract class SimpleAMQQueue<E extends QueueEntryImpl<E,Q,L>, Q extends SimpleA
}
private void deliverMessage(final QueueConsumer<?,E,Q,L> sub, final E entry, boolean batch)
- throws AMQException
{
setLastSeenEntry(sub, entry);
@@ -803,7 +808,7 @@ abstract class SimpleAMQQueue<E extends QueueEntryImpl<E,Q,L>, Q extends SimpleA
sub.send(entry, batch);
}
- private boolean consumerReadyAndHasInterest(final QueueConsumer<?,E,Q,L> sub, final E entry) throws AMQException
+ private boolean consumerReadyAndHasInterest(final QueueConsumer<?,E,Q,L> sub, final E entry)
{
return sub.hasInterest(entry) && (getNextAvailableEntry(sub) == entry);
}
@@ -894,7 +899,7 @@ abstract class SimpleAMQQueue<E extends QueueEntryImpl<E,Q,L>, Q extends SimpleA
_dequeueCount.incrementAndGet();
}
- public boolean resend(final E entry, final QueueConsumer<?,E,Q,L> consumer) throws AMQException
+ public boolean resend(final E entry, final QueueConsumer<?,E,Q,L> consumer)
{
/* TODO : This is wrong as the consumer may be suspended, we should instead change the state of the message
entry to resend and move back the consumer pointer. */
@@ -1170,7 +1175,7 @@ abstract class SimpleAMQQueue<E extends QueueEntryImpl<E,Q,L>, Q extends SimpleA
}
- public void purge(final long request) throws AMQException
+ public void purge(final long request) throws QpidSecurityException
{
clear(request);
}
@@ -1200,17 +1205,17 @@ abstract class SimpleAMQQueue<E extends QueueEntryImpl<E,Q,L>, Q extends SimpleA
}
}
- public long clearQueue() throws AMQException
+ public long clearQueue() throws QpidSecurityException
{
return clear(0l);
}
- private long clear(final long request) throws AMQSecurityException
+ private long clear(final long request) throws QpidSecurityException
{
//Perform ACLs
if (!getVirtualHost().getSecurityManager().authorisePurge(this))
{
- throw new AMQSecurityException("Permission denied: queue " + getName());
+ throw new QpidSecurityException("Permission denied: queue " + getName());
}
QueueEntryIterator<E,Q,L,QueueConsumer<?,E,Q,L>> queueListIterator = _entries.iterator();
@@ -1272,12 +1277,12 @@ abstract class SimpleAMQQueue<E extends QueueEntryImpl<E,Q,L>, Q extends SimpleA
}
// TODO list all thrown exceptions
- public int delete() throws AMQException
+ public int delete() throws QpidSecurityException
{
// Check access
if (!_virtualHost.getSecurityManager().authoriseDelete(this))
{
- throw new AMQSecurityException("Permission denied: " + getName());
+ throw new QpidSecurityException("Permission denied: " + getName());
}
if (!_deleted.getAndSet(true))
@@ -1438,17 +1443,13 @@ abstract class SimpleAMQQueue<E extends QueueEntryImpl<E,Q,L>, Q extends SimpleA
}
- void flushConsumer(QueueConsumer<?,E,Q,L> sub) throws AMQException
+ void flushConsumer(QueueConsumer<?,E,Q,L> sub)
{
- // Access control
- if (!getVirtualHost().getSecurityManager().authoriseConsume(this))
- {
- throw new AMQSecurityException("Permission denied: " + getName());
- }
+
flushConsumer(sub, Long.MAX_VALUE);
}
- boolean flushConsumer(QueueConsumer<?,E,Q,L> sub, long iterations) throws AMQException
+ boolean flushConsumer(QueueConsumer<?,E,Q,L> sub, long iterations)
{
boolean atTail = false;
final boolean keepSendLockHeld = iterations <= SimpleAMQQueue.MAX_ASYNC_DELIVERIES;
@@ -1524,9 +1525,8 @@ abstract class SimpleAMQQueue<E extends QueueEntryImpl<E,Q,L>, Q extends SimpleA
* @param sub the consumer
* @param batch true if processing can be batched
* @return true if we have completed all possible deliveries for this sub.
- * @throws AMQException
*/
- private boolean attemptDelivery(QueueConsumer<?,E,Q,L> sub, boolean batch) throws AMQException
+ private boolean attemptDelivery(QueueConsumer<?,E,Q,L> sub, boolean batch)
{
boolean atTail = false;
@@ -1569,7 +1569,7 @@ abstract class SimpleAMQQueue<E extends QueueEntryImpl<E,Q,L>, Q extends SimpleA
return atTail || !subActive;
}
- protected void advanceAllConsumers() throws AMQException
+ protected void advanceAllConsumers()
{
QueueConsumerList.ConsumerNodeIterator<E,Q,L> consumerNodeIterator = _consumerList.iterator();
while (consumerNodeIterator.advance())
@@ -1588,7 +1588,6 @@ abstract class SimpleAMQQueue<E extends QueueEntryImpl<E,Q,L>, Q extends SimpleA
}
private E getNextAvailableEntry(final QueueConsumer<?,E,Q,L> sub)
- throws AMQException
{
QueueContext<E,Q,L> context = sub.getQueueContext();
if(context != null)
@@ -1666,9 +1665,8 @@ abstract class SimpleAMQQueue<E extends QueueEntryImpl<E,Q,L>, Q extends SimpleA
* ends the current instance
*
* @param runner the Runner to schedule
- * @throws AMQException
*/
- public long processQueue(QueueRunner runner) throws AMQException
+ public long processQueue(QueueRunner runner)
{
long stateChangeCount;
long previousStateChangeCount = Long.MIN_VALUE;
@@ -1789,7 +1787,7 @@ abstract class SimpleAMQQueue<E extends QueueEntryImpl<E,Q,L>, Q extends SimpleA
}
- public void checkMessageStatus() throws AMQException
+ public void checkMessageStatus()
{
QueueEntryIterator<E,Q,L,QueueConsumer<?,E,Q,L>> queueListIterator = _entries.iterator();
@@ -2101,7 +2099,7 @@ abstract class SimpleAMQQueue<E extends QueueEntryImpl<E,Q,L>, Q extends SimpleA
/**
* Checks if there is any notification to send to the listeners
*/
- private void checkForNotification(ServerMessage<?> msg) throws AMQException
+ private void checkForNotification(ServerMessage<?> msg)
{
final Set<NotificationCheck> notificationChecks = getNotificationChecks();
final AMQQueue.NotificationListener listener = _notificationListener;
@@ -2163,11 +2161,6 @@ abstract class SimpleAMQQueue<E extends QueueEntryImpl<E,Q,L>, Q extends SimpleA
{
SimpleAMQQueue.this.enqueue(message, postEnqueueAction);
}
- catch (AMQException e)
- {
- // TODO
- throw new RuntimeException(e);
- }
finally
{
_reference.release();
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/queue/SortedQueue.java b/java/broker-core/src/main/java/org/apache/qpid/server/queue/SortedQueue.java
index 2cae18f3ec..f85f9479bb 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/queue/SortedQueue.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/queue/SortedQueue.java
@@ -19,8 +19,6 @@
*/
package org.apache.qpid.server.queue;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.server.consumer.Consumer;
import org.apache.qpid.server.message.MessageInstance;
import org.apache.qpid.server.message.ServerMessage;
import org.apache.qpid.server.util.Action;
@@ -67,7 +65,6 @@ public class SortedQueue extends OutOfOrderQueue<SortedQueueEntry, SortedQueue,
@Override
public void enqueue(final ServerMessage message,
final Action<? super MessageInstance<?, QueueConsumer<?, SortedQueueEntry, SortedQueue, SortedQueueEntryList>>> action)
- throws AMQException
{
synchronized (_sortedQueueLock)
{
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/queue/SubFlushRunner.java b/java/broker-core/src/main/java/org/apache/qpid/server/queue/SubFlushRunner.java
index c30a48b03a..2100e3c5cd 100755
--- a/java/broker-core/src/main/java/org/apache/qpid/server/queue/SubFlushRunner.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/queue/SubFlushRunner.java
@@ -23,7 +23,6 @@ package org.apache.qpid.server.queue;
import org.apache.log4j.Logger;
-import org.apache.qpid.AMQException;
import org.apache.qpid.server.logging.actors.CurrentActor;
import org.apache.qpid.transport.TransportException;
@@ -66,10 +65,6 @@ class SubFlushRunner implements Runnable
CurrentActor.set(_sub.getLogActor());
complete = getQueue().flushConsumer(_sub, ITERATIONS);
}
- catch (AMQException e)
- {
- _logger.error("Exception during asynchronous delivery by " + toString(), e);
- }
catch (final TransportException transe)
{
final String errorMessage = "Problem during asynchronous delivery by " + toString();
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/security/QpidSecurityException.java b/java/broker-core/src/main/java/org/apache/qpid/server/security/QpidSecurityException.java
new file mode 100644
index 0000000000..b9d9513f9f
--- /dev/null
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/security/QpidSecurityException.java
@@ -0,0 +1,43 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.security;
+
+public class QpidSecurityException extends Exception
+{
+ public QpidSecurityException()
+ {
+ }
+
+ public QpidSecurityException(final String message)
+ {
+ super(message);
+ }
+
+ public QpidSecurityException(final String message, final Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public QpidSecurityException(final Throwable cause)
+ {
+ super(cause);
+ }
+}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/database/HashedUser.java b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/database/HashedUser.java
index b9de1587b5..2b2ecd1d92 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/database/HashedUser.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/database/HashedUser.java
@@ -22,6 +22,7 @@ package org.apache.qpid.server.security.auth.database;
import org.apache.commons.codec.binary.Base64;
import org.apache.log4j.Logger;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
@@ -54,7 +55,7 @@ public class HashedUser implements PasswordPrincipal
}
catch (UnsupportedEncodingException e)
{
- throw new RuntimeException("MD5 encoding not supported, even though the Java standard requires it",e);
+ throw new ServerScopedRuntimeException("MD5 encoding not supported, even though the Java standard requires it",e);
}
Base64 b64 = new Base64();
@@ -86,7 +87,7 @@ public class HashedUser implements PasswordPrincipal
}
catch (NoSuchAlgorithmException e)
{
- throw new RuntimeException("MD5 not supported although Java compliance requires it");
+ throw new ServerScopedRuntimeException("MD5 not supported although Java compliance requires it");
}
for (byte b : data)
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManager.java b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManager.java
index 726284fcce..2cb61b451f 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManager.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManager.java
@@ -20,6 +20,9 @@
package org.apache.qpid.server.security.auth.manager;
import java.io.IOException;
+import java.security.GeneralSecurityException;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
import java.security.Principal;
import java.util.Hashtable;
@@ -49,6 +52,7 @@ import org.apache.qpid.server.security.auth.manager.ldap.AbstractLDAPSSLSocketFa
import org.apache.qpid.server.security.auth.manager.ldap.LDAPSSLSocketFactoryGenerator;
import org.apache.qpid.server.security.auth.sasl.plain.PlainPasswordCallback;
import org.apache.qpid.server.security.auth.sasl.plain.PlainSaslServer;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
import org.apache.qpid.server.util.StringUtil;
import org.apache.qpid.ssl.SSLContextFactory;
@@ -267,11 +271,22 @@ public class SimpleLDAPAuthenticationManager implements AuthenticationManager
sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, _trustStore.getTrustManagers(), null);
}
- catch (Exception e)
+ catch (NoSuchAlgorithmException e)
{
_logger.error("Exception creating SSLContext", e);
- throw new RuntimeException("Error creating SSLContext for trust store : " + _trustStore.getName() , e);
+ throw new ServerScopedRuntimeException("Error creating SSLContext for trust store : " + _trustStore.getName() , e);
}
+ catch (KeyManagementException e)
+ {
+ _logger.error("Exception creating SSLContext", e);
+ throw new ServerScopedRuntimeException("Error creating SSLContext for trust store : " + _trustStore.getName() , e);
+ }
+ catch (GeneralSecurityException e)
+ {
+ _logger.error("Exception creating SSLContext", e);
+ throw new ServerScopedRuntimeException("Error creating SSLContext for trust store : " + _trustStore.getName() , e);
+ }
+
Class<? extends AbstractLDAPSSLSocketFactory> clazz = LDAPSSLSocketFactoryGenerator.createSubClass(clazzName, sslContext.getSocketFactory());
if (_logger.isDebugEnabled())
{
@@ -295,7 +310,7 @@ public class SimpleLDAPAuthenticationManager implements AuthenticationManager
}
catch (NamingException e)
{
- throw new RuntimeException("Unable to establish anonymous connection to the ldap server at " + _providerSearchURL, e);
+ throw new ServerScopedRuntimeException("Unable to establish anonymous connection to the ldap server at " + _providerSearchURL, e);
}
finally
{
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ldap/LDAPSSLSocketFactoryGenerator.java b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ldap/LDAPSSLSocketFactoryGenerator.java
index 5cfc8b7a0b..6aa900ceaa 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ldap/LDAPSSLSocketFactoryGenerator.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ldap/LDAPSSLSocketFactoryGenerator.java
@@ -42,6 +42,7 @@ import org.apache.bcel.generic.InstructionFactory;
import org.apache.bcel.generic.InstructionList;
import org.apache.bcel.generic.MethodGen;
import org.apache.bcel.generic.Type;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
/**
* This class provides a single method, {@link #createSubClass(String, SSLSocketFactory)}. This creates a
@@ -214,19 +215,19 @@ public class LDAPSSLSocketFactoryGenerator
}
catch (IllegalArgumentException e)
{
- throw new RuntimeException(exceptionMessage, e);
+ throw new ServerScopedRuntimeException(exceptionMessage, e);
}
catch (IllegalAccessException e)
{
- throw new RuntimeException(exceptionMessage, e);
+ throw new ServerScopedRuntimeException(exceptionMessage, e);
}
catch (NoSuchFieldException e)
{
- throw new RuntimeException(exceptionMessage, e);
+ throw new ServerScopedRuntimeException(exceptionMessage, e);
}
catch (SecurityException e)
{
- throw new RuntimeException(exceptionMessage, e);
+ throw new ServerScopedRuntimeException(exceptionMessage, e);
}
}
@@ -252,19 +253,19 @@ public class LDAPSSLSocketFactoryGenerator
}
catch (NoSuchFieldException e)
{
- throw new RuntimeException(exceptionMessage, e);
+ throw new ServerScopedRuntimeException(exceptionMessage, e);
}
catch (SecurityException e)
{
- throw new RuntimeException(exceptionMessage, e);
+ throw new ServerScopedRuntimeException(exceptionMessage, e);
}
catch (IllegalArgumentException e)
{
- throw new RuntimeException(exceptionMessage, e);
+ throw new ServerScopedRuntimeException(exceptionMessage, e);
}
catch (IllegalAccessException e)
{
- throw new RuntimeException(exceptionMessage, e);
+ throw new ServerScopedRuntimeException(exceptionMessage, e);
}
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HashedSaslServer.java b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HashedSaslServer.java
index a2d9fa5e3e..6e5dd1aec8 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HashedSaslServer.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HashedSaslServer.java
@@ -20,6 +20,8 @@
*/
package org.apache.qpid.server.security.auth.sasl.crammd5;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
+
import javax.security.auth.callback.CallbackHandler;
import javax.security.sasl.Sasl;
import javax.security.sasl.SaslException;
@@ -60,7 +62,7 @@ public class CRAMMD5HashedSaslServer implements SaslServer
}
}
- throw new RuntimeException("No default SaslServer found for mechanism:" + "CRAM-MD5");
+ throw new ServerScopedRuntimeException("No default SaslServer found for mechanism:" + "CRAM-MD5");
}
public String getMechanismName()
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HexSaslServer.java b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HexSaslServer.java
index e19baaa7c6..8ae0a0044a 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HexSaslServer.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HexSaslServer.java
@@ -20,6 +20,8 @@
*/
package org.apache.qpid.server.security.auth.sasl.crammd5;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
+
import javax.security.auth.callback.CallbackHandler;
import javax.security.sasl.Sasl;
import javax.security.sasl.SaslException;
@@ -60,7 +62,7 @@ public class CRAMMD5HexSaslServer implements SaslServer
}
}
- throw new RuntimeException("No default SaslServer found for mechanism:" + "CRAM-MD5");
+ throw new ServerScopedRuntimeException("No default SaslServer found for mechanism:" + "CRAM-MD5");
}
public String getMechanismName()
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/security/group/FileGroupDatabase.java b/java/broker-core/src/main/java/org/apache/qpid/server/security/group/FileGroupDatabase.java
index c66e7fd4e4..0a02ce38fc 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/security/group/FileGroupDatabase.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/security/group/FileGroupDatabase.java
@@ -34,6 +34,7 @@ import java.util.concurrent.ConcurrentSkipListSet;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
/**
* A group database that reads/writes the following file format:
@@ -181,7 +182,7 @@ public class FileGroupDatabase implements GroupDatabase
}
catch (IOException e)
{
- throw new RuntimeException("Unable to persist change to file " + _groupFile);
+ throw new ServerScopedRuntimeException("Unable to persist change to file " + _groupFile);
}
}
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractJDBCMessageStore.java b/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractJDBCMessageStore.java
index d80fa656e7..740d57f603 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractJDBCMessageStore.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractJDBCMessageStore.java
@@ -43,8 +43,6 @@ import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.log4j.Logger;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.AMQStoreException;
import org.apache.qpid.server.message.EnqueueableMessage;
import org.apache.qpid.server.model.VirtualHost;
import org.apache.qpid.server.plugin.MessageMetaDataType;
@@ -177,7 +175,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
}
@Override
- public void configureConfigStore(VirtualHost virtualHost, ConfigurationRecoveryHandler configRecoveryHandler) throws Exception
+ public void configureConfigStore(VirtualHost virtualHost, ConfigurationRecoveryHandler configRecoveryHandler)
{
_stateManager.attainState(State.INITIALISING);
_configRecoveryHandler = configRecoveryHandler;
@@ -187,7 +185,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
@Override
public void configureMessageStore(VirtualHost virtualHost, MessageStoreRecoveryHandler recoveryHandler,
- TransactionLogRecoveryHandler tlogRecoveryHandler) throws Exception
+ TransactionLogRecoveryHandler tlogRecoveryHandler)
{
if(_stateManager.isInState(State.INITIAL))
{
@@ -201,7 +199,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
completeInitialisation();
}
- private void completeInitialisation() throws ClassNotFoundException, SQLException, AMQStoreException
+ private void completeInitialisation()
{
commonConfiguration();
@@ -209,7 +207,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
}
@Override
- public void activate() throws Exception
+ public void activate()
{
if(_stateManager.isInState(State.INITIALISING))
{
@@ -224,12 +222,28 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
}
if(_messageRecoveryHandler != null)
{
- recoverMessages(_messageRecoveryHandler);
+ try
+ {
+ recoverMessages(_messageRecoveryHandler);
+ }
+ catch (SQLException e)
+ {
+ throw new StoreException("Error encountered when restoring message data from " +
+ "persistent store ", e);
+ }
}
if(_tlogRecoveryHandler != null)
{
- TransactionLogRecoveryHandler.DtxRecordRecoveryHandler dtxrh = recoverQueueEntries(_tlogRecoveryHandler);
- recoverXids(dtxrh);
+ try
+ {
+ TransactionLogRecoveryHandler.DtxRecordRecoveryHandler dtxrh = recoverQueueEntries(_tlogRecoveryHandler);
+ recoverXids(dtxrh);
+ }
+ catch (SQLException e)
+ {
+ throw new StoreException("Error encountered when restoring distributed transaction " +
+ "data from persistent store ", e);
+ }
}
@@ -237,14 +251,24 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
}
private void commonConfiguration()
- throws ClassNotFoundException, SQLException, AMQStoreException
{
- implementationSpecificConfiguration(_virtualHost.getName(), _virtualHost);
- createOrOpenDatabase();
- upgradeIfNecessary();
+ try
+ {
+ implementationSpecificConfiguration(_virtualHost.getName(), _virtualHost);
+ createOrOpenDatabase();
+ upgradeIfNecessary();
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new StoreException("Unable to configure message store ", e);
+ }
+ catch (SQLException e)
+ {
+ throw new StoreException("Unable to configure message store ", e);
+ }
}
- protected void upgradeIfNecessary() throws SQLException, AMQStoreException
+ protected void upgradeIfNecessary() throws SQLException
{
Connection conn = newAutoCommitConnection();
try
@@ -258,7 +282,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
{
if(!rs.next())
{
- throw new AMQStoreException(DB_VERSION_TABLE_NAME + " does not contain the database version");
+ throw new StoreException(DB_VERSION_TABLE_NAME + " does not contain the database version");
}
int version = rs.getInt(1);
switch (version)
@@ -268,7 +292,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
case DB_VERSION:
return;
default:
- throw new AMQStoreException("Unknown database version: " + version);
+ throw new StoreException("Unknown database version: " + version);
}
}
finally
@@ -591,7 +615,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
}
}
- protected void recoverConfiguration(ConfigurationRecoveryHandler recoveryHandler) throws AMQException
+ protected void recoverConfiguration(ConfigurationRecoveryHandler recoveryHandler)
{
try
{
@@ -602,7 +626,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
}
catch (SQLException e)
{
- throw new AMQStoreException("Error recovering persistent state: " + e.getMessage(), e);
+ throw new StoreException("Error recovering persistent state: " + e.getMessage(), e);
}
}
@@ -668,7 +692,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
}
@Override
- public void close() throws Exception
+ public void close()
{
if (_closed.compareAndSet(false, true))
{
@@ -681,7 +705,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
}
- protected abstract void doClose() throws Exception;
+ protected abstract void doClose();
@Override
public StoredMessage addMessage(StorableMessageMetaData metaData)
@@ -756,14 +780,14 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
}
catch (SQLException e)
{
- throw new RuntimeException("Error removing message with id " + messageId + " from database: " + e.getMessage(), e);
+ throw new StoreException("Error removing message with id " + messageId + " from database: " + e.getMessage(), e);
}
}
@Override
- public void create(UUID id, String type, Map<String,Object> attributes) throws AMQStoreException
+ public void create(UUID id, String type, Map<String,Object> attributes) throws StoreException
{
if (_stateManager.isInState(State.ACTIVE))
{
@@ -773,17 +797,17 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
}
@Override
- public void remove(UUID id, String type) throws AMQStoreException
+ public void remove(UUID id, String type) throws StoreException
{
int results = removeConfiguredObject(id);
if (results == 0)
{
- throw new AMQStoreException(type + " with id " + id + " not found");
+ throw new StoreException(type + " with id " + id + " not found");
}
}
@Override
- public void update(UUID id, String type, Map<String, Object> attributes) throws AMQStoreException
+ public void update(UUID id, String type, Map<String, Object> attributes) throws StoreException
{
if (_stateManager.isInState(State.ACTIVE))
{
@@ -852,7 +876,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
protected abstract Connection getConnection() throws SQLException;
- private byte[] convertStringMapToBytes(final Map<String, String> arguments) throws AMQStoreException
+ private byte[] convertStringMapToBytes(final Map<String, String> arguments) throws StoreException
{
byte[] argumentBytes;
if(arguments == null)
@@ -877,7 +901,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
catch (IOException e)
{
// This should never happen
- throw new AMQStoreException(e.getMessage(), e);
+ throw new StoreException(e.getMessage(), e);
}
argumentBytes = bos.toByteArray();
}
@@ -890,7 +914,8 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
return new JDBCTransaction();
}
- public void enqueueMessage(ConnectionWrapper connWrapper, final TransactionLogResource queue, Long messageId) throws AMQStoreException
+ public void enqueueMessage(ConnectionWrapper connWrapper, final TransactionLogResource queue, Long messageId) throws
+ StoreException
{
Connection conn = connWrapper.getConnection();
@@ -927,13 +952,14 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
catch (SQLException e)
{
getLogger().error("Failed to enqueue: " + e.getMessage(), e);
- throw new AMQStoreException("Error writing enqueued message with id " + messageId + " for queue " + (queue instanceof AMQQueue ? ((AMQQueue)queue).getName() : "" ) + " with id " + queue.getId()
+ throw new StoreException("Error writing enqueued message with id " + messageId + " for queue " + (queue instanceof AMQQueue ? ((AMQQueue)queue).getName() : "" ) + " with id " + queue.getId()
+ " to database", e);
}
}
- public void dequeueMessage(ConnectionWrapper connWrapper, final TransactionLogResource queue, Long messageId) throws AMQStoreException
+ public void dequeueMessage(ConnectionWrapper connWrapper, final TransactionLogResource queue, Long messageId) throws
+ StoreException
{
Connection conn = connWrapper.getConnection();
@@ -952,7 +978,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
if(results != 1)
{
- throw new AMQStoreException("Unable to find message with id " + messageId + " on queue " + (queue instanceof AMQQueue ? ((AMQQueue)queue).getName() : "" )
+ throw new StoreException("Unable to find message with id " + messageId + " on queue " + (queue instanceof AMQQueue ? ((AMQQueue)queue).getName() : "" )
+ " with id " + queue.getId());
}
@@ -973,14 +999,14 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
catch (SQLException e)
{
getLogger().error("Failed to dequeue: " + e.getMessage(), e);
- throw new AMQStoreException("Error deleting enqueued message with id " + messageId + " for queue " + (queue instanceof AMQQueue ? ((AMQQueue)queue).getName() : "" )
+ throw new StoreException("Error deleting enqueued message with id " + messageId + " for queue " + (queue instanceof AMQQueue ? ((AMQQueue)queue).getName() : "" )
+ " with id " + queue.getId() + " from database", e);
}
}
private void removeXid(ConnectionWrapper connWrapper, long format, byte[] globalId, byte[] branchId)
- throws AMQStoreException
+ throws StoreException
{
Connection conn = connWrapper.getConnection();
@@ -999,7 +1025,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
if(results != 1)
{
- throw new AMQStoreException("Unable to find message with xid");
+ throw new StoreException("Unable to find message with xid");
}
}
finally
@@ -1025,13 +1051,13 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
catch (SQLException e)
{
getLogger().error("Failed to dequeue: " + e.getMessage(), e);
- throw new AMQStoreException("Error deleting enqueued message with xid", e);
+ throw new StoreException("Error deleting enqueued message with xid", e);
}
}
private void recordXid(ConnectionWrapper connWrapper, long format, byte[] globalId, byte[] branchId,
- Transaction.Record[] enqueues, Transaction.Record[] dequeues) throws AMQStoreException
+ Transaction.Record[] enqueues, Transaction.Record[] dequeues) throws StoreException
{
Connection conn = connWrapper.getConnection();
@@ -1092,7 +1118,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
catch (SQLException e)
{
getLogger().error("Failed to enqueue: " + e.getMessage(), e);
- throw new AMQStoreException("Error writing xid ", e);
+ throw new StoreException("Error writing xid ", e);
}
}
@@ -1118,7 +1144,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
}
- public void commitTran(ConnectionWrapper connWrapper) throws AMQStoreException
+ public void commitTran(ConnectionWrapper connWrapper) throws StoreException
{
try
@@ -1135,7 +1161,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
}
catch (SQLException e)
{
- throw new AMQStoreException("Error commit tx: " + e.getMessage(), e);
+ throw new StoreException("Error commit tx: " + e.getMessage(), e);
}
finally
{
@@ -1143,17 +1169,17 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
}
}
- public StoreFuture commitTranAsync(ConnectionWrapper connWrapper) throws AMQStoreException
+ public StoreFuture commitTranAsync(ConnectionWrapper connWrapper) throws StoreException
{
commitTran(connWrapper);
return StoreFuture.IMMEDIATE_FUTURE;
}
- public void abortTran(ConnectionWrapper connWrapper) throws AMQStoreException
+ public void abortTran(ConnectionWrapper connWrapper) throws StoreException
{
if (connWrapper == null)
{
- throw new AMQStoreException("Fatal internal error: transactional context is empty at abortTran");
+ throw new StoreException("Fatal internal error: transactional context is empty at abortTran");
}
if (getLogger().isDebugEnabled())
@@ -1169,7 +1195,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
}
catch (SQLException e)
{
- throw new AMQStoreException("Error aborting transaction: " + e.getMessage(), e);
+ throw new StoreException("Error aborting transaction: " + e.getMessage(), e);
}
}
@@ -1208,7 +1234,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
if(result == 0)
{
- throw new RuntimeException("Unable to add meta data for message " +messageId);
+ throw new StoreException("Unable to add meta data for message " +messageId);
}
}
finally
@@ -1533,7 +1559,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
}
else
{
- throw new RuntimeException("Meta data not found for message with id " + messageId);
+ throw new StoreException("Meta data not found for message with id " + messageId);
}
}
finally
@@ -1579,7 +1605,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
catch (SQLException e)
{
closeConnection(conn);
- throw new RuntimeException("Error adding content for message " + messageId + ": " + e.getMessage(), e);
+ throw new StoreException("Error adding content for message " + messageId + ": " + e.getMessage(), e);
}
finally
{
@@ -1611,7 +1637,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
if (offset > size)
{
- throw new RuntimeException("Offset " + offset + " is greater than message size " + size
+ throw new StoreException("Offset " + offset + " is greater than message size " + size
+ " for message id " + messageId + "!");
}
@@ -1630,7 +1656,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
}
catch (SQLException e)
{
- throw new RuntimeException("Error retrieving content from offset " + offset + " for message " + messageId + ": " + e.getMessage(), e);
+ throw new StoreException("Error retrieving content from offset " + offset + " for message " + messageId + ": " + e.getMessage(), e);
}
finally
{
@@ -1662,12 +1688,12 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
}
catch (SQLException e)
{
- throw new RuntimeException(e);
+ throw new StoreException(e);
}
}
@Override
- public void enqueueMessage(TransactionLogResource queue, EnqueueableMessage message) throws AMQStoreException
+ public void enqueueMessage(TransactionLogResource queue, EnqueueableMessage message)
{
final StoredMessage storedMessage = message.getStoredMessage();
if(storedMessage instanceof StoredJDBCMessage)
@@ -1678,50 +1704,49 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
}
catch (SQLException e)
{
- throw new AMQStoreException("Exception on enqueuing message " + _messageId, e);
+ throw new StoreException("Exception on enqueuing message into message store" + _messageId, e);
}
}
_storeSizeIncrease += storedMessage.getMetaData().getContentSize();
AbstractJDBCMessageStore.this.enqueueMessage(_connWrapper, queue, message.getMessageNumber());
+
}
@Override
- public void dequeueMessage(TransactionLogResource queue, EnqueueableMessage message) throws AMQStoreException
+ public void dequeueMessage(TransactionLogResource queue, EnqueueableMessage message)
{
AbstractJDBCMessageStore.this.dequeueMessage(_connWrapper, queue, message.getMessageNumber());
-
}
@Override
- public void commitTran() throws AMQStoreException
+ public void commitTran()
{
AbstractJDBCMessageStore.this.commitTran(_connWrapper);
storedSizeChange(_storeSizeIncrease);
}
@Override
- public StoreFuture commitTranAsync() throws AMQStoreException
+ public StoreFuture commitTranAsync()
{
- final StoreFuture storeFuture = AbstractJDBCMessageStore.this.commitTranAsync(_connWrapper);
+ StoreFuture storeFuture = AbstractJDBCMessageStore.this.commitTranAsync(_connWrapper);
storedSizeChange(_storeSizeIncrease);
return storeFuture;
}
@Override
- public void abortTran() throws AMQStoreException
+ public void abortTran()
{
AbstractJDBCMessageStore.this.abortTran(_connWrapper);
}
@Override
- public void removeXid(long format, byte[] globalId, byte[] branchId) throws AMQStoreException
+ public void removeXid(long format, byte[] globalId, byte[] branchId)
{
AbstractJDBCMessageStore.this.removeXid(_connWrapper, format, globalId, branchId);
}
@Override
public void recordXid(long format, byte[] globalId, byte[] branchId, Record[] enqueues, Record[] dequeues)
- throws AMQStoreException
{
AbstractJDBCMessageStore.this.recordXid(_connWrapper, format, globalId, branchId, enqueues, dequeues);
}
@@ -1770,7 +1795,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
}
catch (SQLException e)
{
- throw new RuntimeException(e);
+ throw new StoreException(e);
}
_metaDataRef = new SoftReference<StorableMessageMetaData>(metaData);
}
@@ -1856,7 +1881,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
{
getLogger().debug("Error when trying to flush message " + _messageId + " to store: " + e);
}
- throw new RuntimeException(e);
+ throw new StoreException(e);
}
finally
{
@@ -1938,7 +1963,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
_eventManager.addEventListener(eventListener, events);
}
- private void insertConfiguredObject(ConfiguredObjectRecord configuredObject) throws AMQStoreException
+ private void insertConfiguredObject(ConfiguredObjectRecord configuredObject) throws StoreException
{
if (_stateManager.isInState(State.ACTIVE))
{
@@ -1998,24 +2023,24 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
}
catch (JsonMappingException e)
{
- throw new AMQStoreException("Error inserting of configured object " + configuredObject + " into database: " + e.getMessage(), e);
+ throw new StoreException("Error inserting of configured object " + configuredObject + " into database: " + e.getMessage(), e);
}
catch (JsonGenerationException e)
{
- throw new AMQStoreException("Error inserting of configured object " + configuredObject + " into database: " + e.getMessage(), e);
+ throw new StoreException("Error inserting of configured object " + configuredObject + " into database: " + e.getMessage(), e);
}
catch (IOException e)
{
- throw new AMQStoreException("Error inserting of configured object " + configuredObject + " into database: " + e.getMessage(), e);
+ throw new StoreException("Error inserting of configured object " + configuredObject + " into database: " + e.getMessage(), e);
}
catch (SQLException e)
{
- throw new AMQStoreException("Error inserting of configured object " + configuredObject + " into database: " + e.getMessage(), e);
+ throw new StoreException("Error inserting of configured object " + configuredObject + " into database: " + e.getMessage(), e);
}
}
}
- private int removeConfiguredObject(UUID id) throws AMQStoreException
+ private int removeConfiguredObject(UUID id) throws StoreException
{
int results = 0;
try
@@ -2032,12 +2057,12 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
}
catch (SQLException e)
{
- throw new AMQStoreException("Error deleting of configured object with id " + id + " from database: " + e.getMessage(), e);
+ throw new StoreException("Error deleting of configured object with id " + id + " from database: " + e.getMessage(), e);
}
return results;
}
- public UUID[] removeConfiguredObjects(UUID... objects) throws AMQStoreException
+ public UUID[] removeConfiguredObjects(UUID... objects) throws StoreException
{
Collection<UUID> removed = new ArrayList<UUID>(objects.length);
try
@@ -2061,7 +2086,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
}
catch (SQLException e)
{
- throw new AMQStoreException("Error deleting of configured objects " + Arrays.asList(objects) + " from database: " + e.getMessage(), e);
+ throw new StoreException("Error deleting of configured objects " + Arrays.asList(objects) + " from database: " + e.getMessage(), e);
}
return removed.toArray(new UUID[removed.size()]);
}
@@ -2081,7 +2106,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
return results;
}
- private void updateConfiguredObject(final ConfiguredObjectRecord configuredObject) throws AMQStoreException
+ private void updateConfiguredObject(final ConfiguredObjectRecord configuredObject) throws StoreException
{
if (_stateManager.isInState(State.ACTIVE))
{
@@ -2099,18 +2124,18 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
}
catch (SQLException e)
{
- throw new AMQStoreException("Error updating configured object " + configuredObject + " in database: " + e.getMessage(), e);
+ throw new StoreException("Error updating configured object " + configuredObject + " in database: " + e.getMessage(), e);
}
}
}
@Override
- public void update(ConfiguredObjectRecord... records) throws AMQStoreException
+ public void update(ConfiguredObjectRecord... records) throws StoreException
{
update(false, records);
}
- public void update(boolean createIfNecessary, ConfiguredObjectRecord... records) throws AMQStoreException
+ public void update(boolean createIfNecessary, ConfiguredObjectRecord... records) throws StoreException
{
if (_stateManager.isInState(State.ACTIVE) || _stateManager.isInState(State.ACTIVATING))
{
@@ -2132,7 +2157,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
}
catch (SQLException e)
{
- throw new AMQStoreException("Error updating configured objects in database: " + e.getMessage(), e);
+ throw new StoreException("Error updating configured objects in database: " + e.getMessage(), e);
}
}
@@ -2142,7 +2167,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
private void updateConfiguredObject(ConfiguredObjectRecord configuredObject,
boolean createIfNecessary,
Connection conn)
- throws SQLException, AMQStoreException
+ throws SQLException, StoreException
{
PreparedStatement stmt = conn.prepareStatement(FIND_CONFIGURED_OBJECT);
try
@@ -2209,15 +2234,15 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
}
catch (JsonMappingException e)
{
- throw new AMQStoreException("Error updating configured object " + configuredObject + " in database: " + e.getMessage(), e);
+ throw new StoreException("Error updating configured object " + configuredObject + " in database: " + e.getMessage(), e);
}
catch (JsonGenerationException e)
{
- throw new AMQStoreException("Error updating configured object " + configuredObject + " in database: " + e.getMessage(), e);
+ throw new StoreException("Error updating configured object " + configuredObject + " in database: " + e.getMessage(), e);
}
catch (IOException e)
{
- throw new AMQStoreException("Error updating configured object " + configuredObject + " in database: " + e.getMessage(), e);
+ throw new StoreException("Error updating configured object " + configuredObject + " in database: " + e.getMessage(), e);
}
finally
{
@@ -2226,7 +2251,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
}
- private ConfiguredObjectRecord loadConfiguredObject(final UUID id) throws AMQStoreException
+ private ConfiguredObjectRecord loadConfiguredObject(final UUID id) throws StoreException
{
ConfiguredObjectRecord result = null;
try
@@ -2266,28 +2291,29 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
}
catch (JsonMappingException e)
{
- throw new AMQStoreException("Error loading of configured object with id " + id + " from database: "
+ throw new StoreException("Error loading of configured object with id " + id + " from database: "
+ e.getMessage(), e);
}
catch (JsonParseException e)
{
- throw new AMQStoreException("Error loading of configured object with id " + id + " from database: "
+ throw new StoreException("Error loading of configured object with id " + id + " from database: "
+ e.getMessage(), e);
}
catch (IOException e)
{
- throw new AMQStoreException("Error loading of configured object with id " + id + " from database: "
+ throw new StoreException("Error loading of configured object with id " + id + " from database: "
+ e.getMessage(), e);
}
catch (SQLException e)
{
- throw new AMQStoreException("Error loading of configured object with id " + id + " from database: "
+ throw new StoreException("Error loading of configured object with id " + id + " from database: "
+ e.getMessage(), e);
}
return result;
}
- private void loadConfiguredObjects(ConfigurationRecoveryHandler recoveryHandler) throws SQLException, AMQStoreException
+ private void loadConfiguredObjects(ConfigurationRecoveryHandler recoveryHandler) throws SQLException,
+ StoreException
{
Connection conn = newAutoCommitConnection();
@@ -2311,15 +2337,15 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC
}
catch (JsonMappingException e)
{
- throw new AMQStoreException("Error recovering persistent state: " + e.getMessage(), e);
+ throw new StoreException("Error recovering persistent state: " + e.getMessage(), e);
}
catch (JsonParseException e)
{
- throw new AMQStoreException("Error recovering persistent state: " + e.getMessage(), e);
+ throw new StoreException("Error recovering persistent state: " + e.getMessage(), e);
}
catch (IOException e)
{
- throw new AMQStoreException("Error recovering persistent state: " + e.getMessage(), e);
+ throw new StoreException("Error recovering persistent state: " + e.getMessage(), e);
}
finally
{
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractMemoryMessageStore.java b/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractMemoryMessageStore.java
index 1a7cd72cb6..d72bd1a5bf 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractMemoryMessageStore.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractMemoryMessageStore.java
@@ -22,7 +22,7 @@ package org.apache.qpid.server.store;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
-import org.apache.qpid.AMQStoreException;
+
import org.apache.qpid.server.message.EnqueueableMessage;
import org.apache.qpid.server.model.VirtualHost;
@@ -35,28 +35,28 @@ abstract public class AbstractMemoryMessageStore extends NullMessageStore
private static final Transaction IN_MEMORY_TRANSACTION = new Transaction()
{
@Override
- public StoreFuture commitTranAsync() throws AMQStoreException
+ public StoreFuture commitTranAsync()
{
return StoreFuture.IMMEDIATE_FUTURE;
}
@Override
- public void enqueueMessage(TransactionLogResource queue, EnqueueableMessage message) throws AMQStoreException
+ public void enqueueMessage(TransactionLogResource queue, EnqueueableMessage message)
{
}
@Override
- public void dequeueMessage(TransactionLogResource queue, EnqueueableMessage message) throws AMQStoreException
+ public void dequeueMessage(TransactionLogResource queue, EnqueueableMessage message)
{
}
@Override
- public void commitTran() throws AMQStoreException
+ public void commitTran()
{
}
@Override
- public void abortTran() throws AMQStoreException
+ public void abortTran()
{
}
@@ -80,14 +80,14 @@ abstract public class AbstractMemoryMessageStore extends NullMessageStore
}
@Override
- public void configureConfigStore(VirtualHost virtualHost, ConfigurationRecoveryHandler recoveryHandler) throws Exception
+ public void configureConfigStore(VirtualHost virtualHost, ConfigurationRecoveryHandler recoveryHandler)
{
_stateManager.attainState(State.INITIALISING);
}
@Override
public void configureMessageStore(VirtualHost virtualHost, MessageStoreRecoveryHandler recoveryHandler,
- TransactionLogRecoveryHandler tlogRecoveryHandler) throws Exception
+ TransactionLogRecoveryHandler tlogRecoveryHandler)
{
if(_stateManager.isInState(State.INITIAL))
{
@@ -97,7 +97,7 @@ abstract public class AbstractMemoryMessageStore extends NullMessageStore
}
@Override
- public void activate() throws Exception
+ public void activate()
{
if(_stateManager.isInState(State.INITIALISING))
@@ -131,7 +131,7 @@ abstract public class AbstractMemoryMessageStore extends NullMessageStore
}
@Override
- public void close() throws Exception
+ public void close()
{
if (_closed.compareAndSet(false, true))
{
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationRecoverer.java b/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationRecoverer.java
index 1caaedf6dc..3c5fb44d23 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationRecoverer.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationRecoverer.java
@@ -27,11 +27,11 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.apache.log4j.Logger;
-import org.apache.qpid.AMQStoreException;
import org.apache.qpid.server.configuration.IllegalConfigurationException;
import org.apache.qpid.server.logging.actors.CurrentActor;
import org.apache.qpid.server.logging.messages.ConfigStoreMessages;
import org.apache.qpid.server.logging.subjects.MessageStoreLogSubject;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
import static org.apache.qpid.server.model.VirtualHost.CURRENT_CONFIG_VERSION;
@@ -124,21 +124,13 @@ public class DurableConfigurationRecoverer implements ConfigurationRecoveryHandl
}
}
- try
+ if(!updates.isEmpty())
{
- if(!updates.isEmpty())
- {
- _store.update(true,updates.toArray(new ConfiguredObjectRecord[updates.size()]));
- }
- if(!deletes.isEmpty())
- {
- _store.removeConfiguredObjects(deletes.toArray(new UUID[deletes.size()]));
- }
+ _store.update(true,updates.toArray(new ConfiguredObjectRecord[updates.size()]));
}
- catch (AMQStoreException e)
+ if(!deletes.isEmpty())
{
- // TODO better exception
- throw new RuntimeException("Unable to update config store when upgrading");
+ _store.removeConfiguredObjects(deletes.toArray(new UUID[deletes.size()]));
}
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStore.java b/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStore.java
index 9c9ce7df59..e552b3e073 100755
--- a/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStore.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStore.java
@@ -23,7 +23,6 @@ package org.apache.qpid.server.store;
import java.util.Map;
import java.util.UUID;
-import org.apache.qpid.AMQStoreException;
import org.apache.qpid.server.model.VirtualHost;
public interface DurableConfigurationStore
@@ -44,9 +43,8 @@ public interface DurableConfigurationStore
*
* @param virtualHost
* @param recoveryHandler Handler to be called as the store recovers on start up
- * @throws Exception If any error occurs that means the store is unable to configure itself.
*/
- void configureConfigStore(VirtualHost virtualHost, ConfigurationRecoveryHandler recoveryHandler) throws Exception;
+ void configureConfigStore(VirtualHost virtualHost, ConfigurationRecoveryHandler recoveryHandler);
/**
@@ -56,9 +54,9 @@ public interface DurableConfigurationStore
* @param type The type of the object to persist
* @param attributes the attributes of the object to persist
*
- * @throws AMQStoreException If the operation fails for any reason.
+ * @throws StoreException If the operation fails for any reason.
*/
- void create(UUID id, String type, Map<String, Object> attributes) throws AMQStoreException;
+ void create(UUID id, String type, Map<String, Object> attributes) throws StoreException;
/**
* Removes the specified persistent configured object.
@@ -66,11 +64,11 @@ public interface DurableConfigurationStore
* @param id The id of the object to remove.
* @param type The type of the object to remove
*
- * @throws AMQStoreException If the operation fails for any reason.
+ * @throws StoreException If the operation fails for any reason.
*/
- void remove(UUID id, String type) throws AMQStoreException;
+ void remove(UUID id, String type) throws StoreException;
- public UUID[] removeConfiguredObjects(UUID... objects) throws AMQStoreException;
+ public UUID[] removeConfiguredObjects(UUID... objects) throws StoreException;
/**
@@ -81,13 +79,13 @@ public interface DurableConfigurationStore
* @param type The type of the object to update
* @param attributes the updated attributes
*
- * @throws AMQStoreException If the operation fails for any reason.
+ * @throws StoreException If the operation fails for any reason.
*/
- void update(UUID id, String type, Map<String, Object> attributes) throws AMQStoreException;
+ void update(UUID id, String type, Map<String, Object> attributes) throws StoreException;
- public void update(ConfiguredObjectRecord... records) throws AMQStoreException;
- public void update(boolean createIfNecessary, ConfiguredObjectRecord... records) throws AMQStoreException;
+ public void update(ConfiguredObjectRecord... records) throws StoreException;
+ public void update(boolean createIfNecessary, ConfiguredObjectRecord... records) throws StoreException;
void close() throws Exception;
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStoreHelper.java b/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStoreHelper.java
index eff9bdf433..fc5806ccce 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStoreHelper.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStoreHelper.java
@@ -28,13 +28,13 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
-import org.apache.qpid.AMQStoreException;
-import org.apache.qpid.server.consumer.Consumer;
+
import org.apache.qpid.server.model.Binding;
import org.apache.qpid.server.model.Exchange;
import org.apache.qpid.server.model.LifetimePolicy;
import org.apache.qpid.server.model.Queue;
import org.apache.qpid.server.queue.AMQQueue;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
public class DurableConfigurationStoreHelper
{
@@ -47,7 +47,7 @@ public class DurableConfigurationStoreHelper
Queue.EXCLUSIVE,
Queue.ALTERNATE_EXCHANGE));
- public static void updateQueue(DurableConfigurationStore store, AMQQueue<?,?,?> queue) throws AMQStoreException
+ public static void updateQueue(DurableConfigurationStore store, AMQQueue<?,?,?> queue)
{
Map<String, Object> attributesMap = new LinkedHashMap<String, Object>();
attributesMap.put(Queue.NAME, queue.getName());
@@ -73,7 +73,6 @@ public class DurableConfigurationStoreHelper
}
public static void createQueue(DurableConfigurationStore store, AMQQueue<?,?,?> queue)
- throws AMQStoreException
{
Map<String, Object> attributesMap = new HashMap<String, Object>();
attributesMap.put(Queue.NAME, queue.getName());
@@ -91,35 +90,33 @@ public class DurableConfigurationStoreHelper
attributesMap.put(attrName, queue.getAttribute(attrName));
}
}
- store.create(queue.getId(), QUEUE,attributesMap);
+ store.create(queue.getId(), QUEUE, attributesMap);
}
- public static void removeQueue(DurableConfigurationStore store, AMQQueue queue) throws AMQStoreException
+ public static void removeQueue(DurableConfigurationStore store, AMQQueue queue)
{
store.remove(queue.getId(), QUEUE);
}
public static void createExchange(DurableConfigurationStore store, org.apache.qpid.server.exchange.Exchange exchange)
- throws AMQStoreException
{
Map<String, Object> attributesMap = new HashMap<String, Object>();
attributesMap.put(Exchange.NAME, exchange.getName());
attributesMap.put(Exchange.TYPE, exchange.getTypeName());
attributesMap.put(Exchange.LIFETIME_POLICY, exchange.isAutoDelete() ? LifetimePolicy.AUTO_DELETE.name()
: LifetimePolicy.PERMANENT.name());
+
store.create(exchange.getId(), EXCHANGE, attributesMap);
}
public static void removeExchange(DurableConfigurationStore store, org.apache.qpid.server.exchange.Exchange exchange)
- throws AMQStoreException
{
store.remove(exchange.getId(), EXCHANGE);
}
public static void createBinding(DurableConfigurationStore store, org.apache.qpid.server.binding.Binding binding)
- throws AMQStoreException
{
Map<String, Object> attributesMap = new HashMap<String, Object>();
attributesMap.put(Binding.NAME, binding.getBindingKey());
@@ -130,12 +127,12 @@ public class DurableConfigurationStoreHelper
{
attributesMap.put(Binding.ARGUMENTS, arguments);
}
+
store.create(binding.getId(), BINDING, attributesMap);
}
public static void removeBinding(DurableConfigurationStore store, org.apache.qpid.server.binding.Binding binding)
- throws AMQStoreException
{
store.remove(binding.getId(), BINDING);
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java b/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java
index 9b20c9a780..9fbfba4872 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java
@@ -34,10 +34,12 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
-import org.apache.qpid.AMQStoreException;
+
import org.apache.qpid.server.model.ConfiguredObject;
import org.apache.qpid.server.model.Model;
import org.apache.qpid.server.model.VirtualHost;
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.SerializationConfig;
@@ -66,14 +68,13 @@ public class JsonFileConfigStore implements DurableConfigurationStore
@Override
public void configureConfigStore(final VirtualHost virtualHost, final ConfigurationRecoveryHandler recoveryHandler)
- throws Exception
{
_name = virtualHost.getName();
Object storePathAttr = virtualHost.getAttribute(VirtualHost.CONFIG_STORE_PATH);
if(!(storePathAttr instanceof String))
{
- throw new AMQStoreException("Cannot determine path for configuration storage");
+ throw new StoreException("Cannot determine path for configuration storage");
}
_directoryName = (String) storePathAttr;
_configFileName = _name + ".json";
@@ -86,7 +87,14 @@ public class JsonFileConfigStore implements DurableConfigurationStore
if(!fileExists(_backupFileName))
{
File newFile = new File(_directoryName, _configFileName);
- _objectMapper.writeValue(newFile, Collections.emptyMap());
+ try
+ {
+ _objectMapper.writeValue(newFile, Collections.emptyMap());
+ }
+ catch (IOException e)
+ {
+ throw new StoreException("Could not write configuration file " + newFile, e);
+ }
}
else
{
@@ -110,21 +118,21 @@ public class JsonFileConfigStore implements DurableConfigurationStore
}
}
- private void renameFile(String fromFileName, String toFileName) throws AMQStoreException
+ private void renameFile(String fromFileName, String toFileName)
{
File toFile = new File(_directoryName, toFileName);
if(toFile.exists())
{
if(!toFile.delete())
{
- throw new AMQStoreException("Cannot delete file " + toFile.getAbsolutePath());
+ throw new StoreException("Cannot delete file " + toFile.getAbsolutePath());
}
}
File fromFile = new File(_directoryName, fromFileName);
if(!fromFile.renameTo(toFile))
{
- throw new AMQStoreException("Cannot rename file " + fromFile.getAbsolutePath() + " to " + toFile.getAbsolutePath());
+ throw new StoreException("Cannot rename file " + fromFile.getAbsolutePath() + " to " + toFile.getAbsolutePath());
}
}
@@ -134,7 +142,7 @@ public class JsonFileConfigStore implements DurableConfigurationStore
return file.exists();
}
- private void getFileLock() throws AMQStoreException
+ private void getFileLock()
{
File lockFile = new File(_directoryName, _name + ".lck");
try
@@ -149,7 +157,7 @@ public class JsonFileConfigStore implements DurableConfigurationStore
}
catch (IOException ioe)
{
- throw new AMQStoreException("Cannot create the lock file " + lockFile.getName(), ioe);
+ throw new StoreException("Cannot create the lock file " + lockFile.getName(), ioe);
}
catch(OverlappingFileLockException e)
{
@@ -158,11 +166,11 @@ public class JsonFileConfigStore implements DurableConfigurationStore
if(_fileLock == null)
{
- throw new AMQStoreException("Cannot get lock on file " + lockFile.getAbsolutePath() + ". Is another instance running?");
+ throw new StoreException("Cannot get lock on file " + lockFile.getAbsolutePath() + ". Is another instance running?");
}
}
- private void checkDirectoryIsWritable(String directoryName) throws AMQStoreException
+ private void checkDirectoryIsWritable(String directoryName)
{
File dir = new File(directoryName);
if(dir.exists())
@@ -171,51 +179,68 @@ public class JsonFileConfigStore implements DurableConfigurationStore
{
if(!dir.canWrite())
{
- throw new AMQStoreException("Configuration path " + directoryName + " exists, but is not writable");
+ throw new StoreException("Configuration path " + directoryName + " exists, but is not writable");
}
}
else
{
- throw new AMQStoreException("Configuration path " + directoryName + " exists, but is not a directory");
+ throw new StoreException("Configuration path " + directoryName + " exists, but is not a directory");
}
}
else if(!dir.mkdirs())
{
- throw new AMQStoreException("Cannot create directory " + directoryName);
+ throw new StoreException("Cannot create directory " + directoryName);
}
}
- private void load() throws IOException
+ private void load()
{
- Map data = _objectMapper.readValue(new File(_directoryName,_configFileName),Map.class);
- Collection<Class<? extends ConfiguredObject>> childClasses =
- MODEL.getChildTypes(VirtualHost.class);
- data.remove("modelVersion");
- Object configVersion;
- if((configVersion = data.remove("configVersion")) instanceof Integer)
- {
- _configVersion = (Integer) configVersion;
- }
- for(Class<? extends ConfiguredObject> childClass : childClasses)
+ final File configFile = new File(_directoryName, _configFileName);
+ try
{
- final String type = childClass.getSimpleName();
- String attrName = type.toLowerCase() + "s";
- Object children = data.remove(attrName);
- if(children != null)
+ Map data = _objectMapper.readValue(configFile,Map.class);
+ Collection<Class<? extends ConfiguredObject>> childClasses =
+ MODEL.getChildTypes(VirtualHost.class);
+ data.remove("modelVersion");
+ Object configVersion;
+ if((configVersion = data.remove("configVersion")) instanceof Integer)
{
- if(children instanceof Collection)
+ _configVersion = (Integer) configVersion;
+ }
+ for(Class<? extends ConfiguredObject> childClass : childClasses)
+ {
+ final String type = childClass.getSimpleName();
+ String attrName = type.toLowerCase() + "s";
+ Object children = data.remove(attrName);
+ if(children != null)
{
- for(Object child : (Collection)children)
+ if(children instanceof Collection)
{
- if(child instanceof Map)
+ for(Object child : (Collection)children)
{
- loadChild(childClass, (Map)child, VirtualHost.class, null);
+ if(child instanceof Map)
+ {
+ loadChild(childClass, (Map)child, VirtualHost.class, null);
+ }
}
}
}
}
}
+ catch (JsonMappingException e)
+ {
+ throw new StoreException("Cannot parse the configuration file " + configFile, e);
+ }
+ catch (JsonParseException e)
+ {
+ throw new StoreException("Cannot parse the configuration file " + configFile, e);
+ }
+ catch (IOException e)
+ {
+ throw new StoreException("Could not load the configuration file " + configFile, e);
+ }
+
}
private void loadChild(final Class<? extends ConfiguredObject> clazz,
@@ -286,15 +311,16 @@ public class JsonFileConfigStore implements DurableConfigurationStore
}
@Override
- public synchronized void create(final UUID id, final String type, final Map<String, Object> attributes) throws AMQStoreException
+ public synchronized void create(final UUID id, final String type, final Map<String, Object> attributes) throws
+ StoreException
{
if(_objectsById.containsKey(id))
{
- throw new AMQStoreException("Object with id " + id + " already exists");
+ throw new StoreException("Object with id " + id + " already exists");
}
else if(!CLASS_NAME_MAPPING.containsKey(type))
{
- throw new AMQStoreException("Cannot create object of unknown type " + type);
+ throw new StoreException("Cannot create object of unknown type " + type);
}
else
{
@@ -311,7 +337,7 @@ public class JsonFileConfigStore implements DurableConfigurationStore
}
}
- private void save() throws AMQStoreException
+ private void save()
{
Collection<Class<? extends ConfiguredObject>> childClasses =
MODEL.getChildTypes(VirtualHost.class);
@@ -351,7 +377,7 @@ public class JsonFileConfigStore implements DurableConfigurationStore
}
catch (IOException e)
{
- throw new AMQStoreException("Cannot save to store", e);
+ throw new StoreException("Cannot save to store", e);
}
}
@@ -397,13 +423,13 @@ public class JsonFileConfigStore implements DurableConfigurationStore
}
@Override
- public void remove(final UUID id, final String type) throws AMQStoreException
+ public void remove(final UUID id, final String type) throws StoreException
{
removeConfiguredObjects(id);
}
@Override
- public synchronized UUID[] removeConfiguredObjects(final UUID... objects) throws AMQStoreException
+ public synchronized UUID[] removeConfiguredObjects(final UUID... objects) throws StoreException
{
List<UUID> removedIds = new ArrayList<UUID>();
for(UUID id : objects)
@@ -420,20 +446,21 @@ public class JsonFileConfigStore implements DurableConfigurationStore
}
@Override
- public void update(final UUID id, final String type, final Map<String, Object> attributes) throws AMQStoreException
+ public void update(final UUID id, final String type, final Map<String, Object> attributes) throws
+ StoreException
{
update(false, new ConfiguredObjectRecord(id, type, attributes));
}
@Override
- public void update(final ConfiguredObjectRecord... records) throws AMQStoreException
+ public void update(final ConfiguredObjectRecord... records) throws StoreException
{
update(false, records);
}
@Override
public void update(final boolean createIfNecessary, final ConfiguredObjectRecord... records)
- throws AMQStoreException
+ throws StoreException
{
for(ConfiguredObjectRecord record : records)
{
@@ -445,18 +472,18 @@ public class JsonFileConfigStore implements DurableConfigurationStore
final ConfiguredObjectRecord existingRecord = _objectsById.get(id);
if(!type.equals(existingRecord.getType()))
{
- throw new AMQStoreException("Cannot change the type of record " + id + " from type "
+ throw new StoreException("Cannot change the type of record " + id + " from type "
+ existingRecord.getType() + " to type " + type);
}
}
else if(!createIfNecessary)
{
- throw new AMQStoreException("Cannot update record with id " + id
+ throw new StoreException("Cannot update record with id " + id
+ " of type " + type + " as it does not exist");
}
else if(!CLASS_NAME_MAPPING.containsKey(type))
{
- throw new AMQStoreException("Cannot update record of unknown type " + type);
+ throw new StoreException("Cannot update record of unknown type " + type);
}
}
for(ConfiguredObjectRecord record : records)
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/store/MessageStore.java b/java/broker-core/src/main/java/org/apache/qpid/server/store/MessageStore.java
index 996d71d51d..626b999d72 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/store/MessageStore.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/store/MessageStore.java
@@ -41,9 +41,9 @@ public interface MessageStore
* @throws Exception If any error occurs that means the store is unable to configure itself.
*/
void configureMessageStore(VirtualHost virtualHost, MessageStoreRecoveryHandler messageRecoveryHandler,
- TransactionLogRecoveryHandler tlogRecoveryHandler) throws Exception;
+ TransactionLogRecoveryHandler tlogRecoveryHandler);
- void activate() throws Exception;
+ void activate();
public <T extends StorableMessageMetaData> StoredMessage<T> addMessage(T metaData);
@@ -62,7 +62,7 @@ public interface MessageStore
*
* @throws Exception If the close fails.
*/
- void close() throws Exception;
+ void close();
void addEventListener(EventListener eventListener, Event... events);
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/store/NullMessageStore.java b/java/broker-core/src/main/java/org/apache/qpid/server/store/NullMessageStore.java
index 57dbfabaa4..9100d623cd 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/store/NullMessageStore.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/store/NullMessageStore.java
@@ -21,13 +21,13 @@ package org.apache.qpid.server.store;
import java.util.Map;
import java.util.UUID;
-import org.apache.qpid.AMQStoreException;
+
import org.apache.qpid.server.model.VirtualHost;
public abstract class NullMessageStore implements MessageStore, DurableConfigurationStore
{
@Override
- public void configureConfigStore(VirtualHost virtualHost, ConfigurationRecoveryHandler recoveryHandler) throws Exception
+ public void configureConfigStore(VirtualHost virtualHost, ConfigurationRecoveryHandler recoveryHandler)
{
}
@@ -37,12 +37,12 @@ public abstract class NullMessageStore implements MessageStore, DurableConfigura
}
@Override
- public void update(ConfiguredObjectRecord... records) throws AMQStoreException
+ public void update(ConfiguredObjectRecord... records)
{
}
@Override
- public void update(boolean createIfNecessary, ConfiguredObjectRecord... records) throws AMQStoreException
+ public void update(boolean createIfNecessary, ConfiguredObjectRecord... records)
{
}
@@ -53,7 +53,7 @@ public abstract class NullMessageStore implements MessageStore, DurableConfigura
}
@Override
- public UUID[] removeConfiguredObjects(final UUID... objects) throws AMQStoreException
+ public UUID[] removeConfiguredObjects(final UUID... objects)
{
return objects;
}
@@ -65,12 +65,12 @@ public abstract class NullMessageStore implements MessageStore, DurableConfigura
@Override
public void configureMessageStore(VirtualHost virtualHost, MessageStoreRecoveryHandler recoveryHandler,
- TransactionLogRecoveryHandler tlogRecoveryHandler) throws Exception
+ TransactionLogRecoveryHandler tlogRecoveryHandler)
{
}
@Override
- public void close() throws Exception
+ public void close()
{
}
@@ -93,7 +93,7 @@ public abstract class NullMessageStore implements MessageStore, DurableConfigura
}
@Override
- public void activate() throws Exception
+ public void activate()
{
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/store/MessageStoreClosedException.java b/java/broker-core/src/main/java/org/apache/qpid/server/store/StoreException.java
index b0a736c66c..d63e07810d 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/store/MessageStoreClosedException.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/store/StoreException.java
@@ -18,21 +18,24 @@
* under the License.
*
*/
-
package org.apache.qpid.server.store;
-import org.apache.qpid.AMQException;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
-/**
- * NOTE: this class currently extends AMQException but
- * we should be using AMQExceptions internally in the code base for Protocol errors hence
- * the message store interface should throw a different super class which this should be
- * moved to reflect
- */
-public class MessageStoreClosedException extends AMQException
+public class StoreException extends ServerScopedRuntimeException
{
- public MessageStoreClosedException()
+ public StoreException(final String message)
+ {
+ super(message);
+ }
+
+ public StoreException(final String message, final Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public StoreException(final Throwable cause)
{
- super("Message store closed");
+ super(cause);
}
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/store/Transaction.java b/java/broker-core/src/main/java/org/apache/qpid/server/store/Transaction.java
index 74b91dec2d..6f7afccac0 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/store/Transaction.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/store/Transaction.java
@@ -20,7 +20,6 @@
*/
package org.apache.qpid.server.store;
-import org.apache.qpid.AMQStoreException;
import org.apache.qpid.server.message.EnqueueableMessage;
public interface Transaction
@@ -32,40 +31,35 @@ public interface Transaction
*
* @param queue The queue to place the message on.
* @param message
- * @throws org.apache.qpid.AMQStoreException If the operation fails for any reason.
*/
- void enqueueMessage(TransactionLogResource queue, EnqueueableMessage message) throws AMQStoreException;
+ void enqueueMessage(TransactionLogResource queue, EnqueueableMessage message);
/**
* Extracts a message from a specified queue, in a given transactional context.
*
* @param queue The queue to place the message on.
* @param message The message to dequeue.
- * @throws AMQStoreException If the operation fails for any reason, or if the specified message does not exist.
*/
- void dequeueMessage(TransactionLogResource queue, EnqueueableMessage message) throws AMQStoreException;
+ void dequeueMessage(TransactionLogResource queue, EnqueueableMessage message);
/**
* Commits all operations performed within a given transactional context.
*
- * @throws AMQStoreException If the operation fails for any reason.
*/
- void commitTran() throws AMQStoreException;
+ void commitTran();
/**
* Commits all operations performed within a given transactional context.
*
- * @throws AMQStoreException If the operation fails for any reason.
*/
- StoreFuture commitTranAsync() throws AMQStoreException;
+ StoreFuture commitTranAsync();
/**
* Abandons all operations performed within a given transactional context.
*
- * @throws AMQStoreException If the operation fails for any reason.
*/
- void abortTran() throws AMQStoreException;
+ void abortTran();
public static interface Record
@@ -74,8 +68,8 @@ public interface Transaction
EnqueueableMessage getMessage();
}
- void removeXid(long format, byte[] globalId, byte[] branchId) throws AMQStoreException;
+ void removeXid(long format, byte[] globalId, byte[] branchId);
- void recordXid(long format, byte[] globalId, byte[] branchId, Transaction.Record[] enqueues, Transaction.Record[] dequeues)
- throws AMQStoreException;
+ void recordXid(long format, byte[] globalId, byte[] branchId, Transaction.Record[] enqueues,
+ Transaction.Record[] dequeues);
} \ No newline at end of file
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/txn/AsyncAutoCommitTransaction.java b/java/broker-core/src/main/java/org/apache/qpid/server/txn/AsyncAutoCommitTransaction.java
index 57c67f54cd..013e9f32ed 100755
--- a/java/broker-core/src/main/java/org/apache/qpid/server/txn/AsyncAutoCommitTransaction.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/txn/AsyncAutoCommitTransaction.java
@@ -22,13 +22,10 @@ package org.apache.qpid.server.txn;
import org.apache.log4j.Logger;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.AMQStoreException;
import org.apache.qpid.server.message.EnqueueableMessage;
import org.apache.qpid.server.message.MessageInstance;
import org.apache.qpid.server.message.ServerMessage;
import org.apache.qpid.server.queue.BaseQueue;
-import org.apache.qpid.server.queue.QueueEntry;
import org.apache.qpid.server.store.MessageStore;
import org.apache.qpid.server.store.StoreFuture;
import org.apache.qpid.server.store.Transaction;
@@ -116,11 +113,6 @@ public class AsyncAutoCommitTransaction implements ServerTransaction
addFuture(future, postTransactionAction);
postTransactionAction = null;
}
- catch (AMQException e)
- {
- _logger.error("Error during message dequeue", e);
- throw new RuntimeException("Error during message dequeue", e);
- }
finally
{
rollbackIfNecessary(postTransactionAction, txn);
@@ -199,11 +191,6 @@ public class AsyncAutoCommitTransaction implements ServerTransaction
addFuture(future, postTransactionAction);
postTransactionAction = null;
}
- catch (AMQException e)
- {
- _logger.error("Error during message dequeues", e);
- throw new RuntimeException("Error during message dequeues", e);
- }
finally
{
rollbackIfNecessary(postTransactionAction, txn);
@@ -236,13 +223,7 @@ public class AsyncAutoCommitTransaction implements ServerTransaction
}
addEnqueueFuture(future, postTransactionAction, message.isPersistent());
postTransactionAction = null;
- }
- catch (AMQException e)
- {
- _logger.error("Error during message enqueue", e);
- throw new RuntimeException("Error during message enqueue", e);
- }
- finally
+ }finally
{
rollbackIfNecessary(postTransactionAction, txn);
}
@@ -292,13 +273,7 @@ public class AsyncAutoCommitTransaction implements ServerTransaction
postTransactionAction = null;
- }
- catch (AMQException e)
- {
- _logger.error("Error during message enqueues", e);
- throw new RuntimeException("Error during message enqueues", e);
- }
- finally
+ }finally
{
rollbackIfNecessary(postTransactionAction, txn);
}
@@ -341,17 +316,7 @@ public class AsyncAutoCommitTransaction implements ServerTransaction
{
if (txn != null)
{
- try
- {
- txn.abortTran();
- }
- catch (AMQStoreException e)
- {
- _logger.error("Abort transaction failed", e);
- // Deliberate decision not to re-throw this exception. Rationale: we can only reach here if a previous
- // TransactionLog method has ended in Exception. If we were to re-throw here, we would prevent
- // our caller from receiving the original exception (which is likely to be more revealing of the underlying error).
- }
+ txn.abortTran();
}
if (postTransactionAction != null)
{
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/txn/AutoCommitTransaction.java b/java/broker-core/src/main/java/org/apache/qpid/server/txn/AutoCommitTransaction.java
index 4ea48c6a24..15a5513e11 100755
--- a/java/broker-core/src/main/java/org/apache/qpid/server/txn/AutoCommitTransaction.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/txn/AutoCommitTransaction.java
@@ -22,13 +22,10 @@ package org.apache.qpid.server.txn;
import org.apache.log4j.Logger;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.AMQStoreException;
import org.apache.qpid.server.message.EnqueueableMessage;
import org.apache.qpid.server.message.MessageInstance;
import org.apache.qpid.server.message.ServerMessage;
import org.apache.qpid.server.queue.BaseQueue;
-import org.apache.qpid.server.queue.QueueEntry;
import org.apache.qpid.server.store.MessageStore;
import org.apache.qpid.server.store.Transaction;
import org.apache.qpid.server.store.TransactionLogResource;
@@ -95,11 +92,6 @@ public class AutoCommitTransaction implements ServerTransaction
postTransactionAction.postCommit();
postTransactionAction = null;
}
- catch (AMQException e)
- {
- _logger.error("Error during message dequeue", e);
- throw new RuntimeException("Error during message dequeue", e);
- }
finally
{
rollbackIfNecessary(postTransactionAction, txn);
@@ -140,13 +132,7 @@ public class AutoCommitTransaction implements ServerTransaction
}
postTransactionAction.postCommit();
postTransactionAction = null;
- }
- catch (AMQException e)
- {
- _logger.error("Error during message dequeues", e);
- throw new RuntimeException("Error during message dequeues", e);
- }
- finally
+ }finally
{
rollbackIfNecessary(postTransactionAction, txn);
}
@@ -174,11 +160,6 @@ public class AutoCommitTransaction implements ServerTransaction
postTransactionAction.postCommit();
postTransactionAction = null;
}
- catch (AMQException e)
- {
- _logger.error("Error during message enqueue", e);
- throw new RuntimeException("Error during message enqueue", e);
- }
finally
{
rollbackIfNecessary(postTransactionAction, txn);
@@ -225,13 +206,7 @@ public class AutoCommitTransaction implements ServerTransaction
postTransactionAction = null;
- }
- catch (AMQException e)
- {
- _logger.error("Error during message enqueues", e);
- throw new RuntimeException("Error during message enqueues", e);
- }
- finally
+ }finally
{
rollbackIfNecessary(postTransactionAction, txn);
}
@@ -261,17 +236,7 @@ public class AutoCommitTransaction implements ServerTransaction
{
if (txn != null)
{
- try
- {
- txn.abortTran();
- }
- catch (AMQStoreException e)
- {
- _logger.error("Abort transaction failed", e);
- // Deliberate decision not to re-throw this exception. Rationale: we can only reach here if a previous
- // TransactionLog method has ended in Exception. If we were to re-throw here, we would prevent
- // our caller from receiving the original exception (which is likely to be more revealing of the underlying error).
- }
+ txn.abortTran();
}
if (postTransactionAction != null)
{
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/txn/DtxBranch.java b/java/broker-core/src/main/java/org/apache/qpid/server/txn/DtxBranch.java
index 2505548ab8..e4a89b23c0 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/txn/DtxBranch.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/txn/DtxBranch.java
@@ -28,10 +28,9 @@ import java.util.Map;
import java.util.concurrent.ScheduledFuture;
import org.apache.log4j.Logger;
-import org.apache.qpid.AMQStoreException;
+import org.apache.qpid.server.store.StoreException;
import org.apache.qpid.server.message.EnqueueableMessage;
import org.apache.qpid.server.protocol.AMQSessionModel;
-import org.apache.qpid.server.queue.BaseQueue;
import org.apache.qpid.server.store.MessageStore;
import org.apache.qpid.server.store.Transaction;
import org.apache.qpid.server.store.TransactionLogResource;
@@ -147,15 +146,7 @@ public class DtxBranch
}
setState(State.TIMEDOUT);
- try
- {
- rollback();
- }
- catch (AMQStoreException e)
- {
- _logger.error("Unexpected error when attempting to rollback DtxBranch "+ _xid + " due to timeout", e);
- throw new RuntimeException(e);
- }
+ rollback();
}
});
}
@@ -227,7 +218,7 @@ public class DtxBranch
return false;
}
- public void prepare() throws AMQStoreException
+ public void prepare() throws StoreException
{
if(_logger.isDebugEnabled())
{
@@ -245,7 +236,7 @@ public class DtxBranch
prePrepareTransaction();
}
- public synchronized void rollback() throws AMQStoreException
+ public synchronized void rollback() throws StoreException
{
if(_logger.isDebugEnabled())
{
@@ -287,7 +278,7 @@ public class DtxBranch
_postTransactionActions.clear();
}
- public void commit() throws AMQStoreException
+ public void commit() throws StoreException
{
if(_logger.isDebugEnabled())
{
@@ -328,7 +319,7 @@ public class DtxBranch
_postTransactionActions.clear();
}
- public void prePrepareTransaction() throws AMQStoreException
+ public void prePrepareTransaction() throws StoreException
{
_transaction = _store.newTransaction();
@@ -400,15 +391,8 @@ public class DtxBranch
{
if(_transaction != null)
{
- try
- {
- _state = null;
- _transaction.abortTran();
- }
- catch(AMQStoreException e)
- {
- _logger.error("Error while closing DtxBranch " + _xid, e);
- }
+ _state = null;
+ _transaction.abortTran();
}
}
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/txn/DtxRegistry.java b/java/broker-core/src/main/java/org/apache/qpid/server/txn/DtxRegistry.java
index 117beb82ef..2ac8687411 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/txn/DtxRegistry.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/txn/DtxRegistry.java
@@ -25,7 +25,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.qpid.AMQStoreException;
+import org.apache.qpid.server.store.StoreException;
import org.apache.qpid.server.protocol.AMQSessionModel;
import org.apache.qpid.transport.Xid;
@@ -117,7 +117,7 @@ public class DtxRegistry
}
public synchronized void commit(Xid id, boolean onePhase)
- throws IncorrectDtxStateException, UnknownDtxBranchException, AMQStoreException, RollbackOnlyDtxException, TimeoutDtxException
+ throws IncorrectDtxStateException, UnknownDtxBranchException, StoreException, RollbackOnlyDtxException, TimeoutDtxException
{
DtxBranch branch = getBranch(id);
if(branch != null)
@@ -164,7 +164,7 @@ public class DtxRegistry
public synchronized void prepare(Xid id)
throws UnknownDtxBranchException,
- IncorrectDtxStateException, AMQStoreException, RollbackOnlyDtxException, TimeoutDtxException
+ IncorrectDtxStateException, StoreException, RollbackOnlyDtxException, TimeoutDtxException
{
DtxBranch branch = getBranch(id);
if(branch != null)
@@ -207,7 +207,7 @@ public class DtxRegistry
public synchronized void rollback(Xid id)
throws IncorrectDtxStateException,
UnknownDtxBranchException,
- AMQStoreException, TimeoutDtxException
+ StoreException, TimeoutDtxException
{
DtxBranch branch = getBranch(id);
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/txn/LocalTransaction.java b/java/broker-core/src/main/java/org/apache/qpid/server/txn/LocalTransaction.java
index 4b02d4f8ec..b3d013c99f 100755
--- a/java/broker-core/src/main/java/org/apache/qpid/server/txn/LocalTransaction.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/txn/LocalTransaction.java
@@ -27,10 +27,8 @@ import org.apache.qpid.server.store.TransactionLogResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.qpid.AMQException;
import org.apache.qpid.server.message.ServerMessage;
import org.apache.qpid.server.queue.BaseQueue;
-import org.apache.qpid.server.queue.QueueEntry;
import org.apache.qpid.server.store.MessageStore;
import org.apache.qpid.server.store.Transaction;
@@ -110,11 +108,9 @@ public class LocalTransaction implements ServerTransaction
beginTranIfNecessary();
_transaction.dequeueMessage(queue, message);
-
}
- catch(AMQException e)
+ catch(RuntimeException e)
{
- _logger.error("Error during message dequeues", e);
tidyUpOnError(e);
}
}
@@ -143,17 +139,16 @@ public class LocalTransaction implements ServerTransaction
beginTranIfNecessary();
_transaction.dequeueMessage(queue, message);
}
-
}
+
}
- catch(AMQException e)
+ catch(RuntimeException e)
{
- _logger.error("Error during message dequeues", e);
tidyUpOnError(e);
}
}
- private void tidyUpOnError(Exception e)
+ private void tidyUpOnError(RuntimeException e)
{
try
{
@@ -168,32 +163,20 @@ public class LocalTransaction implements ServerTransaction
_transaction.abortTran();
}
}
- catch (Exception abortException)
- {
- _logger.error("Abort transaction failed while trying to handle previous error", abortException);
- }
finally
{
- resetDetails();
+ resetDetails();
}
}
- throw new RuntimeException(e);
+ throw e;
}
-
private void beginTranIfNecessary()
{
if(_transaction == null)
{
- try
- {
- _transaction = _transactionLog.newTransaction();
- }
- catch (Exception e)
- {
- tidyUpOnError(e);
- }
+ _transaction = _transactionLog.newTransaction();
}
}
@@ -215,10 +198,8 @@ public class LocalTransaction implements ServerTransaction
beginTranIfNecessary();
_transaction.enqueueMessage(queue, message);
}
- catch (Exception e)
+ catch(RuntimeException e)
{
- _logger.error("Error during message enqueue", e);
-
tidyUpOnError(e);
}
}
@@ -245,14 +226,12 @@ public class LocalTransaction implements ServerTransaction
beginTranIfNecessary();
_transaction.enqueueMessage(queue, message);
+
}
}
-
}
- catch (Exception e)
+ catch(RuntimeException e)
{
- _logger.error("Error during message enqueue", e);
-
tidyUpOnError(e);
}
}
@@ -281,12 +260,10 @@ public class LocalTransaction implements ServerTransaction
doPostTransactionActions();
}
- catch (Exception e)
+ catch(RuntimeException e)
{
- _logger.error("Failed to commit transaction", e);
-
doRollbackActions();
- throw new RuntimeException("Failed to commit transaction", e);
+ throw e;
}
finally
{
@@ -348,14 +325,11 @@ public class LocalTransaction implements ServerTransaction
{
doPostTransactionActions();
deferred.run();
-
}
- catch (Exception e)
+ catch (RuntimeException e)
{
- _logger.error("Failed to commit transaction", e);
-
doRollbackActions();
- throw new RuntimeException("Failed to commit transaction", e);
+ throw e;
}
finally
{
@@ -371,7 +345,6 @@ public class LocalTransaction implements ServerTransaction
try
{
doPostTransactionActions();
-
deferred.run();
}
finally
@@ -382,9 +355,8 @@ public class LocalTransaction implements ServerTransaction
return future;
}
- catch (Exception e)
+ catch (RuntimeException e)
{
- _logger.error("Failed to commit transaction", e);
try
{
doRollbackActions();
@@ -393,8 +365,9 @@ public class LocalTransaction implements ServerTransaction
{
resetDetails();
}
- throw new RuntimeException("Failed to commit transaction", e);
+ throw e;
}
+
}
private void doPostTransactionActions()
@@ -425,11 +398,6 @@ public class LocalTransaction implements ServerTransaction
_transaction.abortTran();
}
}
- catch (AMQException e)
- {
- _logger.error("Failed to rollback transaction", e);
- throw new RuntimeException("Failed to rollback transaction", e);
- }
finally
{
try
diff --git a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/state/IllegalStateTransitionException.java b/java/broker-core/src/main/java/org/apache/qpid/server/util/ConnectionScopedRuntimeException.java
index f61553f8a2..a7b527f169 100644
--- a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/state/IllegalStateTransitionException.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/util/ConnectionScopedRuntimeException.java
@@ -18,35 +18,31 @@
* under the License.
*
*/
-package org.apache.qpid.server.protocol.v0_8.state;
+package org.apache.qpid.server.util;
-import org.apache.qpid.AMQException;
+import org.apache.log4j.Logger;
-/**
- * @todo Not an AMQP exception as no status code.
- *
- * @todo Not used! Delete.
- */
-public class IllegalStateTransitionException extends AMQException
+public class ConnectionScopedRuntimeException extends RuntimeException
{
- private AMQState _originalState;
+ private static final Logger LOGGER = Logger.getLogger(ConnectionScopedRuntimeException.class);
- private Class _frame;
- public IllegalStateTransitionException(AMQState originalState, Class frame)
+ public ConnectionScopedRuntimeException(final String message)
{
- super("No valid state transition defined for receiving frame " + frame + " from state " + originalState);
- _originalState = originalState;
- _frame = frame;
+ super(message);
+ LOGGER.error(message);
}
- public AMQState getOriginalState()
+ public ConnectionScopedRuntimeException(final String message, final Throwable cause)
{
- return _originalState;
+ super(message, cause);
+ LOGGER.error(message,cause);
}
- public Class getFrameClass()
+ public ConnectionScopedRuntimeException(final Throwable cause)
{
- return _frame;
+ super(cause);
+ LOGGER.error("Exception occurred", cause);
}
+
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/util/MapJsonSerializer.java b/java/broker-core/src/main/java/org/apache/qpid/server/util/MapJsonSerializer.java
index 2d9ba38555..bd68c9e057 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/util/MapJsonSerializer.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/util/MapJsonSerializer.java
@@ -48,7 +48,7 @@ public class MapJsonSerializer
}
catch (Exception e)
{
- throw new RuntimeException("Failure to serialize map:" + attributeMap, e);
+ throw new ConnectionScopedRuntimeException("Failure to serialize map:" + attributeMap, e);
}
return stringWriter.toString();
}
@@ -62,7 +62,7 @@ public class MapJsonSerializer
}
catch (Exception e)
{
- throw new RuntimeException("Failure to deserialize json:" + json, e);
+ throw new ConnectionScopedRuntimeException("Failure to deserialize json:" + json, e);
}
return attributesMap;
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/util/ServerScopedRuntimeException.java b/java/broker-core/src/main/java/org/apache/qpid/server/util/ServerScopedRuntimeException.java
new file mode 100644
index 0000000000..93ba639af0
--- /dev/null
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/util/ServerScopedRuntimeException.java
@@ -0,0 +1,48 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.util;
+
+import org.apache.log4j.Logger;
+
+public class ServerScopedRuntimeException extends RuntimeException
+{
+ private static final Logger LOGGER = Logger.getLogger(ServerScopedRuntimeException.class);
+
+ public ServerScopedRuntimeException(final String message)
+ {
+ super(message);
+ LOGGER.error(message);
+
+ }
+
+ public ServerScopedRuntimeException(final String message, final Throwable cause)
+ {
+ super(message, cause);
+ LOGGER.error(message, cause);
+ }
+
+ public ServerScopedRuntimeException(final Throwable cause)
+ {
+ super(cause);
+ LOGGER.error("Exception occurred", cause);
+ }
+
+}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java
index 3d42b07117..aa70bb3e8d 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java
@@ -33,8 +33,8 @@ import java.util.concurrent.TimeUnit;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.log4j.Logger;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.AMQSecurityException;
+import org.apache.qpid.server.exchange.AMQUnknownExchangeType;
+import org.apache.qpid.server.security.QpidSecurityException;
import org.apache.qpid.server.configuration.ExchangeConfiguration;
import org.apache.qpid.server.configuration.QueueConfiguration;
import org.apache.qpid.server.configuration.VirtualHostConfiguration;
@@ -70,7 +70,7 @@ import org.apache.qpid.server.store.DurableConfiguredObjectRecoverer;
import org.apache.qpid.server.store.Event;
import org.apache.qpid.server.store.EventListener;
import org.apache.qpid.server.txn.DtxRegistry;
-import org.apache.qpid.server.virtualhost.plugins.QueueExistsException;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
public abstract class AbstractVirtualHost implements VirtualHost, IConnectionRegistry.RegistryChangeListener, EventListener
{
@@ -125,7 +125,7 @@ public abstract class AbstractVirtualHost implements VirtualHost, IConnectionReg
StatisticsGatherer brokerStatisticsGatherer,
SecurityManager parentSecurityManager,
VirtualHostConfiguration hostConfig,
- org.apache.qpid.server.model.VirtualHost virtualHost) throws Exception
+ org.apache.qpid.server.model.VirtualHost virtualHost)
{
if (hostConfig == null)
{
@@ -185,7 +185,7 @@ public abstract class AbstractVirtualHost implements VirtualHost, IConnectionReg
}
abstract protected void initialiseStorage(VirtualHostConfiguration hostConfig,
- org.apache.qpid.server.model.VirtualHost virtualHost) throws Exception;
+ org.apache.qpid.server.model.VirtualHost virtualHost);
public IConnectionRegistry getConnectionRegistry()
{
@@ -292,17 +292,37 @@ public abstract class AbstractVirtualHost implements VirtualHost, IConnectionReg
}
- protected void initialiseModel(VirtualHostConfiguration config) throws ConfigurationException, AMQException
+ protected void initialiseModel(VirtualHostConfiguration config)
{
_logger.debug("Loading configuration for virtualhost: " + config.getName());
+
_exchangeRegistry.initialise(_exchangeFactory);
List<String> exchangeNames = config.getExchanges();
for (String exchangeName : exchangeNames)
{
- configureExchange(config.getExchangeConfiguration(exchangeName));
+ try
+ {
+ configureExchange(config.getExchangeConfiguration(exchangeName));
+ }
+ catch (QpidSecurityException e)
+ {
+ throw new ServerScopedRuntimeException("Could not configure exchange " + exchangeName, e);
+ }
+ catch (UnknownExchangeException e)
+ {
+ throw new ServerScopedRuntimeException("Could not configure exchange " + exchangeName, e);
+ }
+ catch (ReservedExchangeNameException e)
+ {
+ throw new ServerScopedRuntimeException("Could not configure exchange " + exchangeName, e);
+ }
+ catch (AMQUnknownExchangeType e)
+ {
+ throw new ServerScopedRuntimeException("Could not configure exchange " + exchangeName, e);
+ }
}
String[] queueNames = config.getQueueNames();
@@ -310,18 +330,31 @@ public abstract class AbstractVirtualHost implements VirtualHost, IConnectionReg
for (Object queueNameObj : queueNames)
{
String queueName = String.valueOf(queueNameObj);
- configureQueue(config.getQueueConfiguration(queueName));
+ try
+ {
+ configureQueue(config.getQueueConfiguration(queueName));
+ }
+ catch (ConfigurationException e)
+ {
+ throw new ServerScopedRuntimeException("Could not configure queue " + queueName, e);
+ }
+ catch (QpidSecurityException e)
+ {
+ throw new ServerScopedRuntimeException("Could not configure queue " + queueName, e);
+ }
}
}
- private void configureExchange(ExchangeConfiguration exchangeConfiguration) throws AMQException
+ private void configureExchange(ExchangeConfiguration exchangeConfiguration)
+ throws QpidSecurityException, UnknownExchangeException, ReservedExchangeNameException,
+ AMQUnknownExchangeType
{
boolean durable = exchangeConfiguration.getDurable();
boolean autodelete = exchangeConfiguration.getAutoDelete();
try
{
- Exchange newExchange = createExchange(null, exchangeConfiguration.getName(), exchangeConfiguration.getType(), durable, autodelete,
- null);
+ Exchange newExchange = createExchange(null, exchangeConfiguration.getName(),
+ exchangeConfiguration.getType(), durable, autodelete, null);
}
catch(ExchangeExistsException e)
{
@@ -330,7 +363,8 @@ public abstract class AbstractVirtualHost implements VirtualHost, IConnectionReg
}
- private void configureQueue(QueueConfiguration queueConfiguration) throws AMQException, ConfigurationException
+ private void configureQueue(QueueConfiguration queueConfiguration)
+ throws ConfigurationException, QpidSecurityException
{
AMQQueue queue = _queueFactory.createAMQQueueImpl(queueConfiguration);
String queueName = queue.getName();
@@ -380,7 +414,8 @@ public abstract class AbstractVirtualHost implements VirtualHost, IConnectionReg
}
- private void configureBinding(AMQQueue queue, Exchange exchange, String routingKey, Map<String,Object> arguments) throws AMQException
+ private void configureBinding(AMQQueue queue, Exchange exchange, String routingKey, Map<String,Object> arguments)
+ throws QpidSecurityException
{
if (_logger.isInfoEnabled())
{
@@ -487,7 +522,7 @@ public abstract class AbstractVirtualHost implements VirtualHost, IConnectionReg
}
@Override
- public int removeQueue(AMQQueue queue) throws AMQException
+ public int removeQueue(AMQQueue queue) throws QpidSecurityException
{
synchronized (getQueueRegistry())
{
@@ -511,7 +546,7 @@ public abstract class AbstractVirtualHost implements VirtualHost, IConnectionReg
boolean autoDelete,
boolean exclusive,
boolean deleteOnNoConsumer,
- Map<String, Object> arguments) throws AMQException
+ Map<String, Object> arguments) throws QpidSecurityException, QueueExistsException
{
if (queueName == null)
@@ -529,7 +564,7 @@ public abstract class AbstractVirtualHost implements VirtualHost, IConnectionReg
owner))
{
String description = "Permission denied: queue-name '" + queueName + "'";
- throw new AMQSecurityException(description);
+ throw new QpidSecurityException(description);
}
synchronized (_queueRegistry)
@@ -603,7 +638,8 @@ public abstract class AbstractVirtualHost implements VirtualHost, IConnectionReg
boolean durable,
boolean autoDelete,
String alternateExchangeName)
- throws AMQException
+ throws QpidSecurityException, ExchangeExistsException, ReservedExchangeNameException,
+ UnknownExchangeException, AMQUnknownExchangeType
{
synchronized (_exchangeRegistry)
{
@@ -649,7 +685,8 @@ public abstract class AbstractVirtualHost implements VirtualHost, IConnectionReg
}
@Override
- public void removeExchange(Exchange exchange, boolean force) throws AMQException
+ public void removeExchange(Exchange exchange, boolean force)
+ throws QpidSecurityException, ExchangeIsAlternateException, RequiredExchangeException
{
if(exchange.hasReferrers())
{
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/BindingRecoverer.java b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/BindingRecoverer.java
index de6d3d9e75..6aa572d81a 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/BindingRecoverer.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/BindingRecoverer.java
@@ -25,15 +25,16 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.apache.log4j.Logger;
-import org.apache.qpid.AMQException;
import org.apache.qpid.server.binding.Binding;
import org.apache.qpid.server.exchange.Exchange;
import org.apache.qpid.server.exchange.ExchangeRegistry;
import org.apache.qpid.server.model.Queue;
import org.apache.qpid.server.queue.AMQQueue;
+import org.apache.qpid.server.security.QpidSecurityException;
import org.apache.qpid.server.store.AbstractDurableConfiguredObjectRecoverer;
import org.apache.qpid.server.store.UnresolvedDependency;
import org.apache.qpid.server.store.UnresolvedObject;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
public class BindingRecoverer extends AbstractDurableConfiguredObjectRecoverer<Binding>
{
@@ -118,9 +119,11 @@ public class BindingRecoverer extends AbstractDurableConfiguredObjectRecoverer<B
}
return _exchange.getBinding(_bindingName, _queue, _bindingArgumentsMap);
}
- catch (AMQException e)
+ catch (QpidSecurityException e)
{
- throw new RuntimeException(e);
+ throw new ServerScopedRuntimeException("Security Exception thrown when recovering. The recovery " +
+ "thread should not be bound by permissions, this is likely " +
+ "a programming error.",e);
}
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ExchangeExistsException.java b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ExchangeExistsException.java
index f055760efe..4e0e46e57b 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ExchangeExistsException.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ExchangeExistsException.java
@@ -19,10 +19,9 @@ package org.apache.qpid.server.virtualhost;/*
*
*/
-import org.apache.qpid.AMQException;
import org.apache.qpid.server.exchange.Exchange;
-public class ExchangeExistsException extends AMQException
+public class ExchangeExistsException extends Exception
{
private final Exchange _existing;
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ExchangeIsAlternateException.java b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ExchangeIsAlternateException.java
index 4be64a3b94..4674a4a534 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ExchangeIsAlternateException.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ExchangeIsAlternateException.java
@@ -1,4 +1,4 @@
-package org.apache.qpid.server.virtualhost;/*
+/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,10 +18,9 @@ package org.apache.qpid.server.virtualhost;/*
* under the License.
*
*/
+package org.apache.qpid.server.virtualhost;
-import org.apache.qpid.AMQException;
-
-public class ExchangeIsAlternateException extends AMQException
+public class ExchangeIsAlternateException extends Exception
{
public ExchangeIsAlternateException(String name)
{
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ExchangeRecoverer.java b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ExchangeRecoverer.java
index 6ad7014c47..59ff1ce6a1 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ExchangeRecoverer.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ExchangeRecoverer.java
@@ -22,14 +22,16 @@ package org.apache.qpid.server.virtualhost;
import java.util.Map;
import java.util.UUID;
-import org.apache.qpid.AMQException;
+import org.apache.qpid.server.exchange.AMQUnknownExchangeType;
import org.apache.qpid.server.exchange.Exchange;
import org.apache.qpid.server.exchange.ExchangeFactory;
import org.apache.qpid.server.exchange.ExchangeRegistry;
import org.apache.qpid.server.model.LifetimePolicy;
+import org.apache.qpid.server.security.QpidSecurityException;
import org.apache.qpid.server.store.AbstractDurableConfiguredObjectRecoverer;
import org.apache.qpid.server.store.UnresolvedDependency;
import org.apache.qpid.server.store.UnresolvedObject;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
public class ExchangeRecoverer extends AbstractDurableConfiguredObjectRecoverer<Exchange>
{
@@ -80,10 +82,21 @@ public class ExchangeRecoverer extends AbstractDurableConfiguredObjectRecoverer<
_exchange = _exchangeFactory.restoreExchange(id, exchangeName, exchangeType, autoDelete);
_exchangeRegistry.registerExchange(_exchange);
}
- }
+ }/*
catch (AMQException e)
{
throw new RuntimeException("Error recovering exchange uuid " + id + " name " + exchangeName, e);
+ }*/
+ catch (QpidSecurityException e)
+ {
+ throw new ServerScopedRuntimeException("Security Exception thrown when recovering. The recovery " +
+ "thread should not be bound by permissions, this is likely " +
+ "a programming error.",e);
+ }
+ catch (AMQUnknownExchangeType e)
+ {
+ throw new ServerScopedRuntimeException("Unknown exchange type found when attempting to restore " +
+ "exchanges, check classpath", e);
}
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/plugins/QueueExistsException.java b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/QueueExistsException.java
index 54f7d0d172..2fe8ce1caf 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/plugins/QueueExistsException.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/QueueExistsException.java
@@ -18,12 +18,11 @@
* under the License.
*
*/
-package org.apache.qpid.server.virtualhost.plugins;
+package org.apache.qpid.server.virtualhost;
-import org.apache.qpid.AMQException;
import org.apache.qpid.server.queue.AMQQueue;
-public class QueueExistsException extends AMQException
+public class QueueExistsException extends Exception
{
private final AMQQueue _existing;
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/QueueRecoverer.java b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/QueueRecoverer.java
index 02d628da68..fd836fdd98 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/QueueRecoverer.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/QueueRecoverer.java
@@ -26,15 +26,16 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.apache.log4j.Logger;
-import org.apache.qpid.AMQException;
import org.apache.qpid.server.exchange.Exchange;
import org.apache.qpid.server.exchange.ExchangeRegistry;
import org.apache.qpid.server.model.Queue;
import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.queue.QueueFactory;
+import org.apache.qpid.server.security.QpidSecurityException;
import org.apache.qpid.server.store.AbstractDurableConfiguredObjectRecoverer;
import org.apache.qpid.server.store.UnresolvedDependency;
import org.apache.qpid.server.store.UnresolvedObject;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
public class QueueRecoverer extends AbstractDurableConfiguredObjectRecoverer<AMQQueue>
{
@@ -125,9 +126,11 @@ public class QueueRecoverer extends AbstractDurableConfiguredObjectRecoverer<AMQ
false, queueArgumentsMap);
}
}
- catch (AMQException e)
+ catch (QpidSecurityException e)
{
- throw new RuntimeException("Error recovering queue uuid " + _id + " name " + queueName, e);
+ throw new ServerScopedRuntimeException("Security Exception thrown when recovering. The recovery " +
+ "thread should not be bound by permissions, this is likely " +
+ "a programming error.",e);
}
return _queue;
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/RequiredExchangeException.java b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/RequiredExchangeException.java
index da4c9825b1..5073c558da 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/RequiredExchangeException.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/RequiredExchangeException.java
@@ -1,4 +1,4 @@
-package org.apache.qpid.server.virtualhost;/*
+/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,10 +18,9 @@ package org.apache.qpid.server.virtualhost;/*
* under the License.
*
*/
+package org.apache.qpid.server.virtualhost;
-import org.apache.qpid.AMQException;
-
-public class RequiredExchangeException extends AMQException
+public class RequiredExchangeException extends Exception
{
public RequiredExchangeException(String name)
{
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ReservedExchangeNameException.java b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ReservedExchangeNameException.java
index 585f045ad9..2db2227de3 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ReservedExchangeNameException.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ReservedExchangeNameException.java
@@ -19,9 +19,7 @@ package org.apache.qpid.server.virtualhost;/*
*
*/
-import org.apache.qpid.AMQException;
-
-public class ReservedExchangeNameException extends AMQException
+public class ReservedExchangeNameException extends Exception
{
private final String _name;
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/StandardVirtualHost.java b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/StandardVirtualHost.java
index b7e51d88d3..3ab6a57839 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/StandardVirtualHost.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/StandardVirtualHost.java
@@ -29,6 +29,7 @@ import org.apache.qpid.server.store.DurableConfigurationStoreCreator;
import org.apache.qpid.server.store.MessageStore;
import org.apache.qpid.server.store.MessageStoreCreator;
import org.apache.qpid.server.store.OperationalLoggingListener;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
public class StandardVirtualHost extends AbstractVirtualHost
{
@@ -39,29 +40,47 @@ public class StandardVirtualHost extends AbstractVirtualHost
StandardVirtualHost(VirtualHostRegistry virtualHostRegistry,
StatisticsGatherer brokerStatisticsGatherer,
org.apache.qpid.server.security.SecurityManager parentSecurityManager,
- VirtualHostConfiguration hostConfig, VirtualHost virtualHost) throws Exception
+ VirtualHostConfiguration hostConfig, VirtualHost virtualHost)
{
super(virtualHostRegistry, brokerStatisticsGatherer, parentSecurityManager, hostConfig, virtualHost);
}
- private MessageStore initialiseMessageStore(VirtualHostConfiguration hostConfig, VirtualHost virtualHost) throws Exception
+ private MessageStore initialiseMessageStore(VirtualHostConfiguration hostConfig, VirtualHost virtualHost)
{
final Object storeTypeAttr = virtualHost.getAttribute(VirtualHost.STORE_TYPE);
String storeType = storeTypeAttr == null ? null : String.valueOf(storeTypeAttr);
MessageStore messageStore = null;
if (storeType == null)
{
- final Class<?> clazz = Class.forName(hostConfig.getMessageStoreClass());
- final Object o = clazz.newInstance();
+ try
+ {
+ final Class<?> clazz = Class.forName(hostConfig.getMessageStoreClass());
+ final Object o = clazz.newInstance();
+
+ if (!(o instanceof MessageStore))
+ {
+ throw new ClassCastException(clazz + " does not implement " + MessageStore.class);
+ }
- if (!(o instanceof MessageStore))
+ messageStore = (MessageStore) o;
+ }
+ catch (ClassNotFoundException e)
{
- throw new ClassCastException(clazz + " does not implement " + MessageStore.class);
+ throw new ServerScopedRuntimeException("Failed to fina virtual host message store implementation, " +
+ "check the classpath and the configuration", e);
+ }
+ catch (InstantiationException e)
+ {
+ throw new ServerScopedRuntimeException("Failed to initialise virtual host store, " +
+ "check the configuration", e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new ServerScopedRuntimeException("Failed to initialise virtual host store, " +
+ "check the configuration", e);
}
-
- messageStore = (MessageStore) o;
}
else
{
@@ -76,7 +95,7 @@ public class StandardVirtualHost extends AbstractVirtualHost
return messageStore;
}
- private DurableConfigurationStore initialiseConfigurationStore(VirtualHost virtualHost) throws Exception
+ private DurableConfigurationStore initialiseConfigurationStore(VirtualHost virtualHost)
{
DurableConfigurationStore configurationStore;
final Object storeTypeAttr = virtualHost.getAttribute(VirtualHost.CONFIG_STORE_TYPE);
@@ -99,7 +118,7 @@ public class StandardVirtualHost extends AbstractVirtualHost
}
- protected void initialiseStorage(VirtualHostConfiguration hostConfig, VirtualHost virtualHost) throws Exception
+ protected void initialiseStorage(VirtualHostConfiguration hostConfig, VirtualHost virtualHost)
{
_messageStore = initialiseMessageStore(hostConfig, virtualHost);
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/StandardVirtualHostFactory.java b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/StandardVirtualHostFactory.java
index 08f35c08f9..c28bcb977f 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/StandardVirtualHostFactory.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/StandardVirtualHostFactory.java
@@ -46,7 +46,7 @@ public class StandardVirtualHostFactory implements VirtualHostFactory
StatisticsGatherer brokerStatisticsGatherer,
org.apache.qpid.server.security.SecurityManager parentSecurityManager,
VirtualHostConfiguration hostConfig,
- org.apache.qpid.server.model.VirtualHost virtualHost) throws Exception
+ org.apache.qpid.server.model.VirtualHost virtualHost)
{
return new StandardVirtualHost(virtualHostRegistry, brokerStatisticsGatherer, parentSecurityManager, hostConfig, virtualHost);
}
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/UnknownExchangeException.java b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/UnknownExchangeException.java
index 5704126f62..9b9029d330 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/UnknownExchangeException.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/UnknownExchangeException.java
@@ -1,4 +1,4 @@
-package org.apache.qpid.server.virtualhost;/*
+/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,10 +18,9 @@ package org.apache.qpid.server.virtualhost;/*
* under the License.
*
*/
+package org.apache.qpid.server.virtualhost;
-import org.apache.qpid.AMQException;
-
-public class UnknownExchangeException extends AMQException
+public class UnknownExchangeException extends Exception
{
private final String _exchangeName;
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java
index 7034311d84..7cd9045af8 100755
--- a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java
@@ -24,19 +24,18 @@ import java.util.Collection;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ScheduledFuture;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.AMQSecurityException;
+
+import org.apache.qpid.server.exchange.AMQUnknownExchangeType;
import org.apache.qpid.common.Closeable;
import org.apache.qpid.server.configuration.VirtualHostConfiguration;
import org.apache.qpid.server.connection.IConnectionRegistry;
import org.apache.qpid.server.exchange.Exchange;
import org.apache.qpid.server.message.MessageDestination;
-import org.apache.qpid.server.message.MessageNode;
import org.apache.qpid.server.message.MessageSource;
import org.apache.qpid.server.plugin.ExchangeType;
import org.apache.qpid.server.protocol.LinkRegistry;
import org.apache.qpid.server.queue.AMQQueue;
-import org.apache.qpid.server.queue.QueueRegistry;
+import org.apache.qpid.server.security.QpidSecurityException;
import org.apache.qpid.server.security.SecurityManager;
import org.apache.qpid.server.stats.StatisticsGatherer;
import org.apache.qpid.server.store.DurableConfigurationStore;
@@ -58,7 +57,7 @@ public interface VirtualHost extends DurableConfigurationStore.Source, Closeable
Collection<AMQQueue> getQueues();
- int removeQueue(AMQQueue queue) throws AMQException;
+ int removeQueue(AMQQueue queue) throws QpidSecurityException;
AMQQueue createQueue(UUID id,
String queueName,
@@ -67,7 +66,7 @@ public interface VirtualHost extends DurableConfigurationStore.Source, Closeable
boolean autoDelete,
boolean exclusive,
boolean deleteOnNoConsumer,
- Map<String, Object> arguments) throws AMQException;
+ Map<String, Object> arguments) throws QueueExistsException, QpidSecurityException;
Exchange createExchange(UUID id,
@@ -76,9 +75,11 @@ public interface VirtualHost extends DurableConfigurationStore.Source, Closeable
boolean durable,
boolean autoDelete,
String alternateExchange)
- throws AMQException;
+ throws QpidSecurityException, ExchangeExistsException, ReservedExchangeNameException,
+ UnknownExchangeException, AMQUnknownExchangeType;
- void removeExchange(Exchange exchange, boolean force) throws AMQException;
+ void removeExchange(Exchange exchange, boolean force) throws QpidSecurityException, ExchangeIsAlternateException,
+ RequiredExchangeException;
MessageDestination getMessageDestination(String name);
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostConfigRecoveryHandler.java b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostConfigRecoveryHandler.java
index 6e36cdfa94..302c61e491 100755
--- a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostConfigRecoveryHandler.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostConfigRecoveryHandler.java
@@ -26,8 +26,6 @@ import java.util.TreeMap;
import java.util.UUID;
import org.apache.log4j.Logger;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.AMQStoreException;
import org.apache.qpid.server.exchange.ExchangeFactory;
import org.apache.qpid.server.exchange.ExchangeRegistry;
import org.apache.qpid.server.logging.actors.CurrentActor;
@@ -138,18 +136,8 @@ public class VirtualHostConfigRecoveryHandler implements
public void postCommit()
{
- try
- {
-
- queue.enqueue(message, null);
- ref.release();
- }
- catch (AMQException e)
- {
- _logger.error("Unable to enqueue message " + message.getMessageNumber() + " into " +
- "queue " + queue.getName() + " (from XA transaction)", e);
- throw new RuntimeException(e);
- }
+ queue.enqueue(message, null);
+ ref.release();
}
public void onRollback()
@@ -228,17 +216,8 @@ public class VirtualHostConfigRecoveryHandler implements
}
- try
- {
- branch.setState(DtxBranch.State.PREPARED);
- branch.prePrepareTransaction();
- }
- catch (AMQStoreException e)
- {
- _logger.error("Unexpected database exception when attempting to prepare a recovered XA transaction " +
- xidAsString(id), e);
- throw new RuntimeException(e);
- }
+ branch.setState(DtxBranch.State.PREPARED);
+ branch.prePrepareTransaction();
}
private static StringBuilder xidAsString(Xid id)
@@ -269,74 +248,66 @@ public class VirtualHostConfigRecoveryHandler implements
public void queueEntry(final UUID queueId, long messageId)
{
AMQQueue queue = _virtualHost.getQueue(queueId);
- try
+ if(queue != null)
{
- if(queue != null)
- {
- String queueName = queue.getName();
- ServerMessage message = _recoveredMessages.get(messageId);
- _unusedMessages.remove(messageId);
+ String queueName = queue.getName();
+ ServerMessage message = _recoveredMessages.get(messageId);
+ _unusedMessages.remove(messageId);
- if(message != null)
- {
-
-
- if (_logger.isDebugEnabled())
- {
- _logger.debug("On recovery, delivering " + message.getMessageNumber() + " to " + queueName);
- }
-
- Integer count = _queueRecoveries.get(queueName);
- if (count == null)
- {
- count = 0;
- }
+ if(message != null)
+ {
- queue.enqueue(message,null);
- _queueRecoveries.put(queueName, ++count);
+ if (_logger.isDebugEnabled())
+ {
+ _logger.debug("On recovery, delivering " + message.getMessageNumber() + " to " + queueName);
}
- else
+
+ Integer count = _queueRecoveries.get(queueName);
+ if (count == null)
{
- _logger.warn("Message id " + messageId + " referenced in log as enqueued in queue " + queueName + " is unknown, entry will be discarded");
- Transaction txn = _store.newTransaction();
- txn.dequeueMessage(queue, new DummyMessage(messageId));
- txn.commitTranAsync();
+ count = 0;
}
+
+ queue.enqueue(message,null);
+
+ _queueRecoveries.put(queueName, ++count);
}
else
{
- _logger.warn("Message id " + messageId + " in log references queue with id " + queueId + " which is not in the configuration, entry will be discarded");
+ _logger.warn("Message id " + messageId + " referenced in log as enqueued in queue " + queueName + " is unknown, entry will be discarded");
Transaction txn = _store.newTransaction();
- TransactionLogResource mockQueue =
- new TransactionLogResource()
- {
- @Override
- public String getName()
- {
- return "<<UNKNOWN>>";
- }
-
- @Override
- public UUID getId()
- {
- return queueId;
- }
-
- @Override
- public boolean isDurable()
- {
- return false;
- }
- };
- txn.dequeueMessage(mockQueue, new DummyMessage(messageId));
+ txn.dequeueMessage(queue, new DummyMessage(messageId));
txn.commitTranAsync();
}
-
}
- catch(AMQException e)
+ else
{
- throw new RuntimeException(e);
+ _logger.warn("Message id " + messageId + " in log references queue with id " + queueId + " which is not in the configuration, entry will be discarded");
+ Transaction txn = _store.newTransaction();
+ TransactionLogResource mockQueue =
+ new TransactionLogResource()
+ {
+ @Override
+ public String getName()
+ {
+ return "<<UNKNOWN>>";
+ }
+
+ @Override
+ public UUID getId()
+ {
+ return queueId;
+ }
+
+ @Override
+ public boolean isDurable()
+ {
+ return false;
+ }
+ };
+ txn.dequeueMessage(mockQueue, new DummyMessage(messageId));
+ txn.commitTranAsync();
}
}
diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/configuration/updater/TaskExecutorTest.java b/java/broker-core/src/test/java/org/apache/qpid/server/configuration/updater/TaskExecutorTest.java
index 27d7dd1241..9dc4fb768e 100644
--- a/java/broker-core/src/test/java/org/apache/qpid/server/configuration/updater/TaskExecutorTest.java
+++ b/java/broker-core/src/test/java/org/apache/qpid/server/configuration/updater/TaskExecutorTest.java
@@ -42,6 +42,7 @@ import org.apache.qpid.server.logging.actors.CurrentActor;
import org.apache.qpid.server.logging.actors.TestLogActor;
import org.apache.qpid.server.model.State;
import org.apache.qpid.server.security.SecurityManager;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
public class TaskExecutorTest extends TestCase
{
@@ -90,7 +91,7 @@ public class TaskExecutorTest extends TestCase
{
try
{
- Future<?> f = _executor.submit(new NeverEndingCallable(waitForCallLatch));
+ Future<Void> f = _executor.submit(new NeverEndingCallable(waitForCallLatch));
submitLatch.countDown();
f.get();
}
@@ -100,7 +101,14 @@ public class TaskExecutorTest extends TestCase
{
e = (Exception) e.getCause();
}
- submitExceptions.add(e);
+ if(e instanceof RuntimeException && e.getCause() instanceof Exception)
+ {
+ submitExceptions.add((Exception)e.getCause());
+ }
+ else
+ {
+ submitExceptions.add(e);
+ }
}
}
};
@@ -133,10 +141,10 @@ public class TaskExecutorTest extends TestCase
public void testSubmitAndWait() throws Exception
{
_executor.start();
- Object result = _executor.submitAndWait(new Callable<String>()
+ Object result = _executor.submitAndWait(new TaskExecutor.Task<Object>()
{
@Override
- public String call() throws Exception
+ public String call()
{
return "DONE";
}
@@ -186,11 +194,11 @@ public class TaskExecutorTest extends TestCase
_executor.start();
try
{
- _executor.submitAndWait(new Callable<Void>()
+ _executor.submitAndWait(new TaskExecutor.Task<Object>()
{
@Override
- public Void call() throws Exception
+ public Void call()
{
throw exception;
}
@@ -203,29 +211,6 @@ public class TaskExecutorTest extends TestCase
}
}
- public void testSubmitAndWaitPassesOriginalCheckedException()
- {
- final Exception exception = new Exception();
- _executor.start();
- try
- {
- _executor.submitAndWait(new Callable<Void>()
- {
-
- @Override
- public Void call() throws Exception
- {
- throw exception;
- }
- });
- fail("Exception is expected");
- }
- catch (Exception e)
- {
- assertEquals("Unexpected exception", exception, e.getCause());
- }
- }
-
public void testSubmitAndWaitCurrentActorAndSecurityManagerSubjectAreRespected() throws Exception
{
_executor.start();
@@ -238,10 +223,10 @@ public class TaskExecutorTest extends TestCase
{
CurrentActor.set(actor);
SecurityManager.setThreadSubject(subject);
- _executor.submitAndWait(new Callable<Void>()
+ _executor.submitAndWait(new TaskExecutor.Task<Object>()
{
@Override
- public Void call() throws Exception
+ public Void call()
{
taskLogActor.set(CurrentActor.get());
taskSubject.set(SecurityManager.getThreadSubject());
@@ -258,16 +243,16 @@ public class TaskExecutorTest extends TestCase
assertEquals("Unexpected security manager subject", subject, taskSubject.get());
}
- private class SubjectRetriever implements Callable<Subject>
+ private class SubjectRetriever implements TaskExecutor.Task<Subject>
{
@Override
- public Subject call() throws Exception
+ public Subject call()
{
return Subject.getSubject(AccessController.getContext());
}
}
- private class NeverEndingCallable implements Callable<Void>
+ private class NeverEndingCallable implements TaskExecutor.Task<Void>
{
private CountDownLatch _waitLatch;
@@ -278,7 +263,7 @@ public class TaskExecutorTest extends TestCase
}
@Override
- public Void call() throws Exception
+ public Void call()
{
if (_waitLatch != null)
{
@@ -288,7 +273,14 @@ public class TaskExecutorTest extends TestCase
// wait forever
synchronized (this)
{
- this.wait();
+ try
+ {
+ this.wait();
+ }
+ catch (InterruptedException e)
+ {
+ throw new ServerScopedRuntimeException(e);
+ }
}
return null;
}
diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/consumer/MockConsumer.java b/java/broker-core/src/test/java/org/apache/qpid/server/consumer/MockConsumer.java
index a9b99503ec..5a12a411cf 100644
--- a/java/broker-core/src/test/java/org/apache/qpid/server/consumer/MockConsumer.java
+++ b/java/broker-core/src/test/java/org/apache/qpid/server/consumer/MockConsumer.java
@@ -21,7 +21,6 @@
package org.apache.qpid.server.consumer;
-import org.apache.qpid.AMQException;
import org.apache.qpid.protocol.AMQConstant;
import org.apache.qpid.server.filter.FilterManager;
import org.apache.qpid.server.filter.Filterable;
@@ -153,7 +152,7 @@ public class MockConsumer implements ConsumerTarget
{
}
- public void send(MessageInstance entry, boolean batch) throws AMQException
+ public void send(MessageInstance entry, boolean batch)
{
if (messages.contains(entry))
{
@@ -205,7 +204,7 @@ public class MockConsumer implements ConsumerTarget
}
- public void queueEmpty() throws AMQException
+ public void queueEmpty()
{
}
@@ -243,7 +242,7 @@ public class MockConsumer implements ConsumerTarget
}
@Override
- public void close() throws AMQException
+ public void close()
{
}
@@ -255,7 +254,7 @@ public class MockConsumer implements ConsumerTarget
@Override
public void checkTransactionStatus(long openWarn, long openClose,
- long idleWarn, long idleClose) throws AMQException
+ long idleWarn, long idleClose)
{
}
@@ -340,7 +339,7 @@ public class MockConsumer implements ConsumerTarget
}
@Override
- public void close(AMQConstant cause, String message) throws AMQException
+ public void close(AMQConstant cause, String message)
{
}
}
@@ -394,13 +393,12 @@ public class MockConsumer implements ConsumerTarget
@Override
public void close(AMQConstant cause, String message)
- throws AMQException
{
}
@Override
public void closeSession(AMQSessionModel session, AMQConstant cause,
- String message) throws AMQException
+ String message)
{
}
diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/exchange/DefaultExchangeFactoryTest.java b/java/broker-core/src/test/java/org/apache/qpid/server/exchange/DefaultExchangeFactoryTest.java
index f57ef037b3..c5ff2a8900 100644
--- a/java/broker-core/src/test/java/org/apache/qpid/server/exchange/DefaultExchangeFactoryTest.java
+++ b/java/broker-core/src/test/java/org/apache/qpid/server/exchange/DefaultExchangeFactoryTest.java
@@ -25,7 +25,6 @@ import java.util.Collection;
import java.util.List;
import java.util.UUID;
-import org.apache.qpid.AMQException;
import org.apache.qpid.server.plugin.ExchangeType;
import org.apache.qpid.server.virtualhost.VirtualHost;
import org.apache.qpid.test.utils.QpidTestCase;
@@ -179,7 +178,7 @@ public class DefaultExchangeFactoryTest extends QpidTestCase
@Override
public Exchange newInstance(UUID id, VirtualHost host, String name, boolean durable,
- boolean autoDelete) throws AMQException
+ boolean autoDelete)
{
return null;
}
diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/exchange/FanoutExchangeTest.java b/java/broker-core/src/test/java/org/apache/qpid/server/exchange/FanoutExchangeTest.java
index 4449cf7645..8cbc6b49ca 100644
--- a/java/broker-core/src/test/java/org/apache/qpid/server/exchange/FanoutExchangeTest.java
+++ b/java/broker-core/src/test/java/org/apache/qpid/server/exchange/FanoutExchangeTest.java
@@ -33,9 +33,7 @@ import java.util.Set;
import java.util.UUID;
import junit.framework.TestCase;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.AMQInternalException;
-import org.apache.qpid.AMQSecurityException;
+import org.apache.qpid.server.security.QpidSecurityException;
import org.apache.qpid.common.AMQPFilterTypes;
import org.apache.qpid.server.logging.LogActor;
import org.apache.qpid.server.logging.actors.CurrentActor;
@@ -54,7 +52,7 @@ public class FanoutExchangeTest extends TestCase
private FanoutExchange _exchange;
private VirtualHost _virtualHost;
- public void setUp() throws AMQException
+ public void setUp()
{
CurrentActor.setDefault(mock(LogActor.class));
@@ -85,28 +83,28 @@ public class FanoutExchangeTest extends TestCase
assertFalse("calling isBound(AMQQueue) with null queue should return false", _exchange.isBound((AMQQueue) null));
}
- public void testIsBoundStringMapAMQQueue() throws AMQSecurityException, AMQInternalException
+ public void testIsBoundStringMapAMQQueue() throws QpidSecurityException
{
AMQQueue queue = bindQueue();
assertTrue("Should return true for a bound queue",
_exchange.isBound("matters", null, queue));
}
- public void testIsBoundStringAMQQueue() throws AMQSecurityException, AMQInternalException
+ public void testIsBoundStringAMQQueue() throws QpidSecurityException
{
AMQQueue queue = bindQueue();
assertTrue("Should return true for a bound queue",
_exchange.isBound("matters", queue));
}
- public void testIsBoundAMQQueue() throws AMQSecurityException, AMQInternalException
+ public void testIsBoundAMQQueue() throws QpidSecurityException
{
AMQQueue queue = bindQueue();
assertTrue("Should return true for a bound queue",
_exchange.isBound(queue));
}
- private AMQQueue bindQueue() throws AMQSecurityException, AMQInternalException
+ private AMQQueue bindQueue() throws QpidSecurityException
{
AMQQueue queue = mockQueue();
_exchange.addBinding("matters", queue, null);
diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java b/java/broker-core/src/test/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java
index 7c62530301..fdaa147ae6 100644
--- a/java/broker-core/src/test/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java
+++ b/java/broker-core/src/test/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java
@@ -29,8 +29,7 @@ import java.util.Map;
import java.util.Set;
import java.util.UUID;
import junit.framework.TestCase;
-import org.apache.qpid.AMQInternalException;
-import org.apache.qpid.AMQSecurityException;
+import org.apache.qpid.server.security.QpidSecurityException;
import org.apache.qpid.common.AMQPFilterTypes;
import org.apache.qpid.server.logging.LogActor;
import org.apache.qpid.server.logging.actors.CurrentActor;
@@ -119,7 +118,7 @@ public class HeadersExchangeTest extends TestCase
}
private void bind(String bindingKey, Map<String, Object> arguments, AMQQueue q)
- throws AMQSecurityException, AMQInternalException
+ throws QpidSecurityException
{
_exchange.addBinding(bindingKey,q,arguments);
}
diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/exchange/TopicExchangeTest.java b/java/broker-core/src/test/java/org/apache/qpid/server/exchange/TopicExchangeTest.java
index 8cab2e9058..573f4a4aaa 100644
--- a/java/broker-core/src/test/java/org/apache/qpid/server/exchange/TopicExchangeTest.java
+++ b/java/broker-core/src/test/java/org/apache/qpid/server/exchange/TopicExchangeTest.java
@@ -23,9 +23,7 @@ package org.apache.qpid.server.exchange;
import java.util.List;
import junit.framework.Assert;
-import org.apache.qpid.AMQException;
import org.apache.qpid.server.binding.Binding;
-import org.apache.qpid.server.consumer.Consumer;
import org.apache.qpid.server.message.InstanceProperties;
import org.apache.qpid.server.message.MessageReference;
import org.apache.qpid.server.message.ServerMessage;
@@ -72,7 +70,7 @@ public class TopicExchangeTest extends QpidTestCase
}
}
- public void testNoRoute() throws AMQException
+ public void testNoRoute() throws Exception
{
AMQQueue<?,?,?> queue = _vhost.createQueue(UUIDGenerator.generateRandomUUID(), "a*#b", false, null, false, false,
false, null);
@@ -84,7 +82,7 @@ public class TopicExchangeTest extends QpidTestCase
Assert.assertEquals(0, queue.getMessageCount());
}
- public void testDirectMatch() throws AMQException
+ public void testDirectMatch() throws Exception
{
AMQQueue<?,?,?> queue = _vhost.createQueue(UUIDGenerator.generateRandomUUID(), "ab", false, null, false, false,
false, null);
@@ -107,7 +105,7 @@ public class TopicExchangeTest extends QpidTestCase
}
- public void testStarMatch() throws AMQException
+ public void testStarMatch() throws Exception
{
AMQQueue<?,?,?> queue = _vhost.createQueue(UUIDGenerator.generateRandomUUID(), "a*", false, null, false, false, false, null);
_exchange.registerQueue(new Binding(null, "a.*",queue, _exchange, null));
@@ -138,7 +136,7 @@ public class TopicExchangeTest extends QpidTestCase
Assert.assertEquals(0, queue.getMessageCount());
}
- public void testHashMatch() throws AMQException
+ public void testHashMatch() throws Exception
{
AMQQueue<?,?,?> queue = _vhost.createQueue(UUIDGenerator.generateRandomUUID(), "a#", false, null, false, false, false, null);
_exchange.registerQueue(new Binding(null, "a.#",queue, _exchange, null));
@@ -189,7 +187,7 @@ public class TopicExchangeTest extends QpidTestCase
}
- public void testMidHash() throws AMQException
+ public void testMidHash() throws Exception
{
AMQQueue<?,?,?> queue = _vhost.createQueue(UUIDGenerator.generateRandomUUID(), "a", false, null, false, false,
false, null);
@@ -215,7 +213,7 @@ public class TopicExchangeTest extends QpidTestCase
}
- public void testMatchAfterHash() throws AMQException
+ public void testMatchAfterHash() throws Exception
{
AMQQueue<?,?,?> queue = _vhost.createQueue(UUIDGenerator.generateRandomUUID(), "a#", false, null, false, false,
false, null);
@@ -254,7 +252,7 @@ public class TopicExchangeTest extends QpidTestCase
}
- public void testHashAfterHash() throws AMQException
+ public void testHashAfterHash() throws Exception
{
AMQQueue<?,?,?> queue = _vhost.createQueue(UUIDGenerator.generateRandomUUID(), "a#", false, null, false, false,
false, null);
@@ -276,7 +274,7 @@ public class TopicExchangeTest extends QpidTestCase
}
- public void testHashHash() throws AMQException
+ public void testHashHash() throws Exception
{
AMQQueue<?,?,?> queue = _vhost.createQueue(UUIDGenerator.generateRandomUUID(), "a#", false, null, false, false,
false, null);
@@ -298,7 +296,7 @@ public class TopicExchangeTest extends QpidTestCase
}
- public void testSubMatchFails() throws AMQException
+ public void testSubMatchFails() throws Exception
{
AMQQueue queue = _vhost.createQueue(UUIDGenerator.generateRandomUUID(), "a", false, null, false, false,
false, null);
@@ -311,7 +309,7 @@ public class TopicExchangeTest extends QpidTestCase
}
- private int routeMessage(String routingKey, long messageNumber) throws AMQException
+ private int routeMessage(String routingKey, long messageNumber)
{
ServerMessage message = mock(ServerMessage.class);
when(message.getRoutingKey()).thenReturn(routingKey);
@@ -328,7 +326,7 @@ public class TopicExchangeTest extends QpidTestCase
return queues.size();
}
- public void testMoreRouting() throws AMQException
+ public void testMoreRouting() throws Exception
{
AMQQueue queue = _vhost.createQueue(UUIDGenerator.generateRandomUUID(), "a", false, null, false, false,
false, null);
@@ -342,7 +340,7 @@ public class TopicExchangeTest extends QpidTestCase
}
- public void testMoreQueue() throws AMQException
+ public void testMoreQueue() throws Exception
{
AMQQueue queue = _vhost.createQueue(UUIDGenerator.generateRandomUUID(), "a", false, null, false, false,
false, null);
diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/logging/actors/AMQPConnectionActorTest.java b/java/broker-core/src/test/java/org/apache/qpid/server/logging/actors/AMQPConnectionActorTest.java
index 8b7f9ec5ca..bee2930fd7 100644
--- a/java/broker-core/src/test/java/org/apache/qpid/server/logging/actors/AMQPConnectionActorTest.java
+++ b/java/broker-core/src/test/java/org/apache/qpid/server/logging/actors/AMQPConnectionActorTest.java
@@ -20,7 +20,6 @@
*/
package org.apache.qpid.server.logging.actors;
-import org.apache.qpid.AMQException;
import org.apache.qpid.server.logging.LogMessage;
import org.apache.qpid.server.logging.LogSubject;
@@ -79,7 +78,7 @@ public class AMQPConnectionActorTest extends BaseConnectionActorTestCase
logs.get(0).toString().contains("/ch:"));
}
- public void testConnectionLoggingOff() throws Exception, AMQException
+ public void testConnectionLoggingOff() throws Exception
{
setStatusUpdatesEnabled(false);
diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/logging/actors/CurrentActorTest.java b/java/broker-core/src/test/java/org/apache/qpid/server/logging/actors/CurrentActorTest.java
index 1fc42fe636..300fcd70d3 100644
--- a/java/broker-core/src/test/java/org/apache/qpid/server/logging/actors/CurrentActorTest.java
+++ b/java/broker-core/src/test/java/org/apache/qpid/server/logging/actors/CurrentActorTest.java
@@ -22,7 +22,6 @@ package org.apache.qpid.server.logging.actors;
import org.apache.commons.configuration.ConfigurationException;
-import org.apache.qpid.AMQException;
import org.apache.qpid.server.protocol.AMQSessionModel;
import org.apache.qpid.server.logging.LogActor;
import org.apache.qpid.server.logging.NullRootMessageLogger;
@@ -66,10 +65,9 @@ public class CurrentActorTest extends BaseConnectionActorTestCase
* And then finally validates that removing the Connection actor results
* in there being no actors set.
*
- * @throws AMQException
* @throws org.apache.commons.configuration.ConfigurationException
*/
- public void testLIFO() throws AMQException, ConfigurationException
+ public void testLIFO() throws ConfigurationException
{
assertTrue("Unexpected actor: " + CurrentActor.get(), CurrentActor.get() instanceof TestLogActor);
AMQPConnectionActor connectionActor = new AMQPConnectionActor(getConnection(),
diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java b/java/broker-core/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java
index febce9ea2e..35ffd08863 100644
--- a/java/broker-core/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java
+++ b/java/broker-core/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java
@@ -36,8 +36,6 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
-
-import org.apache.qpid.AMQException;
import org.apache.qpid.exchange.ExchangeDefaults;
import org.apache.qpid.server.configuration.BrokerProperties;
import org.apache.qpid.server.configuration.QueueConfiguration;
@@ -98,7 +96,7 @@ public class AMQQueueFactoryTest extends QpidTestCase
}
- private void delegateVhostQueueCreation() throws AMQException
+ private void delegateVhostQueueCreation() throws Exception
{
final ArgumentCaptor<UUID> id = ArgumentCaptor.forClass(UUID.class);
final ArgumentCaptor<String> queueName = ArgumentCaptor.forClass(String.class);
@@ -152,7 +150,7 @@ public class AMQQueueFactoryTest extends QpidTestCase
}).when(_queueRegistry).registerQueue(capturedQueue.capture());
}
- private void mockExchangeCreation() throws AMQException
+ private void mockExchangeCreation() throws Exception
{
final ArgumentCaptor<UUID> idCapture = ArgumentCaptor.forClass(UUID.class);
final ArgumentCaptor<String> exchangeNameCapture = ArgumentCaptor.forClass(String.class);
@@ -260,9 +258,8 @@ public class AMQQueueFactoryTest extends QpidTestCase
/**
* Tests that setting the {@link QueueArgumentsConverter#X_QPID_DLQ_ENABLED} argument true does
* cause the alternate exchange to be set and DLQ to be produced.
- * @throws AMQException
*/
- public void testDeadLetterQueueEnabled() throws AMQException
+ public void testDeadLetterQueueEnabled() throws Exception
{
Map<String,Object> attributes = Collections.singletonMap(Queue.CREATE_DLQ_ON_CREATION, (Object) true);
@@ -303,7 +300,6 @@ public class AMQQueueFactoryTest extends QpidTestCase
/**
* Tests that the deadLetterQueues/maximumDeliveryCount settings from the configuration
* are not applied to the DLQ itself.
- * @throws AMQException
*/
public void testDeadLetterQueueDoesNotInheritDLQorMDCSettings() throws Exception
{
@@ -349,9 +345,8 @@ public class AMQQueueFactoryTest extends QpidTestCase
/**
* Tests that setting the {@link QueueArgumentsConverter#X_QPID_DLQ_ENABLED} argument false does not
* result in the alternate exchange being set and DLQ being created.
- * @throws AMQException
*/
- public void testDeadLetterQueueDisabled() throws AMQException
+ public void testDeadLetterQueueDisabled() throws Exception
{
Map<String,Object> attributes = Collections.singletonMap(Queue.CREATE_DLQ_ON_CREATION, (Object) false);
@@ -384,9 +379,8 @@ public class AMQQueueFactoryTest extends QpidTestCase
* Tests that setting the {@link QueueArgumentsConverter#X_QPID_DLQ_ENABLED} argument true but
* creating an auto-delete queue, does not result in the alternate exchange
* being set and DLQ being created.
- * @throws AMQException
*/
- public void testDeadLetterQueueNotCreatedForAutodeleteQueues() throws AMQException
+ public void testDeadLetterQueueNotCreatedForAutodeleteQueues() throws Exception
{
Map<String,Object> attributes = Collections.singletonMap(Queue.CREATE_DLQ_ON_CREATION, (Object) true);
diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/queue/MockAMQQueue.java b/java/broker-core/src/test/java/org/apache/qpid/server/queue/MockAMQQueue.java
index d1bc5effc0..c462468819 100644
--- a/java/broker-core/src/test/java/org/apache/qpid/server/queue/MockAMQQueue.java
+++ b/java/broker-core/src/test/java/org/apache/qpid/server/queue/MockAMQQueue.java
@@ -20,20 +20,17 @@
*/
package org.apache.qpid.server.queue;
-import org.apache.qpid.AMQException;
import org.apache.qpid.server.binding.Binding;
import org.apache.qpid.server.configuration.QueueConfiguration;
import org.apache.qpid.server.exchange.Exchange;
import org.apache.qpid.server.filter.FilterManager;
import org.apache.qpid.server.logging.LogSubject;
import org.apache.qpid.server.message.InstanceProperties;
-import org.apache.qpid.server.message.MessageInstance;
import org.apache.qpid.server.message.ServerMessage;
import org.apache.qpid.server.protocol.AMQSessionModel;
import org.apache.qpid.server.security.AuthorizationHolder;
import org.apache.qpid.server.consumer.Consumer;
import org.apache.qpid.server.consumer.ConsumerTarget;
-import org.apache.qpid.server.store.StorableMessageMetaData;
import org.apache.qpid.server.txn.ServerTransaction;
import org.apache.qpid.server.util.Action;
import org.apache.qpid.server.virtualhost.VirtualHost;
@@ -213,7 +210,7 @@ public class MockAMQQueue implements AMQQueue
}
@Override
- public boolean resend(final QueueEntry entry, final Consumer consumer) throws AMQException
+ public boolean resend(final QueueEntry entry, final Consumer consumer)
{
return false;
}
@@ -225,7 +222,7 @@ public class MockAMQQueue implements AMQQueue
}
@Override
- public void enqueue(final ServerMessage message, final Action action) throws AMQException
+ public void enqueue(final ServerMessage message, final Action action)
{
}
@@ -241,7 +238,7 @@ public class MockAMQQueue implements AMQQueue
final FilterManager filters,
final Class messageClass,
final String consumerName,
- final EnumSet options) throws AMQException
+ final EnumSet options)
{
return new QueueConsumer(filters, messageClass, options.contains(Consumer.Option.ACQUIRES),
options.contains(Consumer.Option.SEES_REQUEUES), consumerName,
@@ -332,7 +329,7 @@ public class MockAMQQueue implements AMQQueue
return _deleted;
}
- public int delete() throws AMQException
+ public int delete()
{
_deleted = true;
return getMessageCount();
@@ -347,11 +344,6 @@ public class MockAMQQueue implements AMQQueue
{
}
- public boolean resend(QueueEntry entry, QueueConsumer consumer) throws AMQException
- {
- return false;
- }
-
@Override
public void removeQueueDeleteTask(final Action task)
{
@@ -451,7 +443,7 @@ public class MockAMQQueue implements AMQQueue
}
- public void checkMessageStatus() throws AMQException
+ public void checkMessageStatus()
{
}
@@ -461,7 +453,7 @@ public class MockAMQQueue implements AMQQueue
return null;
}
- public void flushConsumer(Consumer sub) throws AMQException
+ public void flushConsumer(Consumer sub)
{
}
diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/queue/MockMessageInstance.java b/java/broker-core/src/test/java/org/apache/qpid/server/queue/MockMessageInstance.java
index 386bb46044..4df8f91ede 100644
--- a/java/broker-core/src/test/java/org/apache/qpid/server/queue/MockMessageInstance.java
+++ b/java/broker-core/src/test/java/org/apache/qpid/server/queue/MockMessageInstance.java
@@ -20,7 +20,6 @@
*/
package org.apache.qpid.server.queue;
-import org.apache.qpid.AMQException;
import org.apache.qpid.server.filter.Filterable;
import org.apache.qpid.server.message.AMQMessageHeader;
import org.apache.qpid.server.message.InstanceProperties;
@@ -71,7 +70,7 @@ public class MockMessageInstance implements MessageInstance<MockMessageInstance,
}
- public boolean expired() throws AMQException
+ public boolean expired()
{
return false;
}
@@ -128,7 +127,7 @@ public class MockMessageInstance implements MessageInstance<MockMessageInstance,
}
@Override
- public boolean resend() throws AMQException
+ public boolean resend()
{
return false;
}
diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/queue/PriorityQueueTest.java b/java/broker-core/src/test/java/org/apache/qpid/server/queue/PriorityQueueTest.java
index 56cd29b0bd..acddd49c04 100644
--- a/java/broker-core/src/test/java/org/apache/qpid/server/queue/PriorityQueueTest.java
+++ b/java/broker-core/src/test/java/org/apache/qpid/server/queue/PriorityQueueTest.java
@@ -23,9 +23,6 @@ package org.apache.qpid.server.queue;
import java.util.Collections;
import junit.framework.AssertionFailedError;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.server.logging.LogActor;
-import org.apache.qpid.server.logging.actors.CurrentActor;
import org.apache.qpid.server.message.AMQMessageHeader;
import org.apache.qpid.server.message.MessageInstance;
import org.apache.qpid.server.message.ServerMessage;
@@ -36,7 +33,6 @@ import java.util.EnumSet;
import org.apache.qpid.server.model.Queue;
import org.apache.qpid.server.consumer.Consumer;
-import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class PriorityQueueTest extends SimpleAMQQueueTestBase
@@ -49,7 +45,7 @@ public class PriorityQueueTest extends SimpleAMQQueueTestBase
super.setUp();
}
- public void testPriorityOrdering() throws AMQException, InterruptedException
+ public void testPriorityOrdering() throws Exception, InterruptedException
{
// Enqueue messages in order
@@ -102,7 +98,7 @@ public class PriorityQueueTest extends SimpleAMQQueueTestBase
}
- protected ServerMessage createMessage(Long id, byte i) throws AMQException
+ protected ServerMessage createMessage(Long id, byte i)
{
ServerMessage msg = super.createMessage(id);
@@ -111,7 +107,7 @@ public class PriorityQueueTest extends SimpleAMQQueueTestBase
return msg;
}
- protected ServerMessage createMessage(Long id) throws AMQException
+ protected ServerMessage createMessage(Long id)
{
return createMessage(id, (byte) 0);
}
diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/queue/QueueEntryImplTestBase.java b/java/broker-core/src/test/java/org/apache/qpid/server/queue/QueueEntryImplTestBase.java
index b67b2dda32..66e4286df7 100644
--- a/java/broker-core/src/test/java/org/apache/qpid/server/queue/QueueEntryImplTestBase.java
+++ b/java/broker-core/src/test/java/org/apache/qpid/server/queue/QueueEntryImplTestBase.java
@@ -20,7 +20,6 @@ package org.apache.qpid.server.queue;
import junit.framework.TestCase;
-import org.apache.qpid.AMQException;
import org.apache.qpid.server.consumer.ConsumerTarget;
import org.apache.qpid.server.logging.LogActor;
import org.apache.qpid.server.logging.RootMessageLogger;
@@ -48,7 +47,7 @@ public abstract class QueueEntryImplTestBase extends TestCase
protected QueueEntryImpl _queueEntry2;
protected QueueEntryImpl _queueEntry3;
- public abstract QueueEntryImpl getQueueEntryImpl(int msgId) throws AMQException;
+ public abstract QueueEntryImpl getQueueEntryImpl(int msgId);
public abstract void testCompareTo();
diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/queue/QueueEntryListTestBase.java b/java/broker-core/src/test/java/org/apache/qpid/server/queue/QueueEntryListTestBase.java
index 3af268c189..07d00daba5 100644
--- a/java/broker-core/src/test/java/org/apache/qpid/server/queue/QueueEntryListTestBase.java
+++ b/java/broker-core/src/test/java/org/apache/qpid/server/queue/QueueEntryListTestBase.java
@@ -21,7 +21,6 @@ package org.apache.qpid.server.queue;
import junit.framework.TestCase;
-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;
@@ -39,7 +38,7 @@ public abstract class QueueEntryListTestBase<E extends QueueEntry<E,Q,C>, Q exte
public abstract L getTestList(boolean newList);
public abstract long getExpectedFirstMsgId();
public abstract int getExpectedListLength();
- public abstract ServerMessage getTestMessageToAdd() throws AMQException;
+ public abstract ServerMessage getTestMessageToAdd();
public void testGetQueue()
{
@@ -52,9 +51,8 @@ public abstract class QueueEntryListTestBase<E extends QueueEntry<E,Q,C>, Q exte
* Test to add a message with properties specific to the queue type.
* @see QueueEntryListTestBase#getTestList()
* @see QueueEntryListTestBase#getTestMessageToAdd()
- * @throws AMQException
*/
- public void testAddSpecificMessage() throws AMQException
+ public void testAddSpecificMessage()
{
final L list = getTestList();
list.add(getTestMessageToAdd());
@@ -73,9 +71,8 @@ public abstract class QueueEntryListTestBase<E extends QueueEntry<E,Q,C>, Q exte
* Test to add a generic mock message.
* @see QueueEntryListTestBase#getTestList()
* @see QueueEntryListTestBase#getExpectedListLength()
- * @throws AMQException
*/
- public void testAddGenericMessage() throws AMQException
+ public void testAddGenericMessage()
{
final L list = getTestList();
final ServerMessage message = createServerMessage(666l);
diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueTestBase.java b/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueTestBase.java
index 45001bda50..1934349a62 100644
--- a/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueTestBase.java
+++ b/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueTestBase.java
@@ -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 extends QueueEntryImpl<E,Q,L>, Q extends
}
}
- public void testCreateQueue() throws AMQException
+ public void testCreateQueue() throws Exception
{
_queue.stop();
try
@@ -129,7 +128,7 @@ abstract class SimpleAMQQueueTestBase<E extends QueueEntryImpl<E,Q,L>, Q extends
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 extends QueueEntryImpl<E,Q,L>, Q extends
}
- public void testRegisterConsumerThenEnqueueMessage() throws AMQException
+ public void testRegisterConsumerThenEnqueueMessage() throws Exception
{
ServerMessage messageA = createMessage(new Long(24));
@@ -188,7 +187,7 @@ abstract class SimpleAMQQueueTestBase<E extends QueueEntryImpl<E,Q,L>, Q extends
}
- 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 extends QueueEntryImpl<E,Q,L>, Q extends
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 extends QueueEntryImpl<E,Q,L>, Q extends
Consumer.Option.SEES_REQUEUES));
}
- catch (AMQException e)
+ catch (MessageSource.ExistingExclusiveConsumer e)
{
ex = e;
}
@@ -476,7 +475,7 @@ abstract class SimpleAMQQueueTestBase<E extends QueueEntryImpl<E,Q,L>, Q extends
EnumSet.of(Consumer.Option.EXCLUSIVE));
}
- catch (AMQException e)
+ catch (MessageSource.ExistingConsumerPreventsExclusive e)
{
ex = e;
}
@@ -499,14 +498,8 @@ abstract class SimpleAMQQueueTestBase<E extends QueueEntryImpl<E,Q,L>, Q extends
{
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 extends QueueEntryImpl<E,Q,L>, Q extends
* 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 extends QueueEntryImpl<E,Q,L>, Q extends
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 extends QueueEntryImpl<E,Q,L>, Q extends
{
// 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 extends QueueEntryImpl<E,Q,L>, Q extends
}
- protected ServerMessage createMessage(Long id) throws AMQException
+ protected ServerMessage createMessage(Long id)
{
AMQMessageHeader header = mock(AMQMessageHeader.class);
when(header.getMessageId()).thenReturn(String.valueOf(id));
diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleQueueEntryImplTest.java b/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleQueueEntryImplTest.java
index 36425761be..9457d59300 100644
--- a/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleQueueEntryImplTest.java
+++ b/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleQueueEntryImplTest.java
@@ -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 extends QueueEntryImplTestBase
}
- public QueueEntryImpl getQueueEntryImpl(int msgId) throws AMQException
+ public QueueEntryImpl getQueueEntryImpl(int msgId)
{
ServerMessage message = mock(ServerMessage.class);
when(message.getMessageNumber()).thenReturn((long)msgId);
diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryListTest.java b/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryListTest.java
index b6b3843ad2..f8953bb7cc 100644
--- a/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryListTest.java
+++ b/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryListTest.java
@@ -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 extends QueueEntryListTestBase<SortedQueue
return 67L;
}
- public ServerMessage getTestMessageToAdd() throws AMQException
+ public ServerMessage getTestMessageToAdd()
{
return generateTestMessage(1, "test value");
}
@@ -151,7 +150,7 @@ public class SortedQueueEntryListTest extends QueueEntryListTestBase<SortedQueue
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);
diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryTest.java b/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryTest.java
index a406c1c26f..25d6dbba60 100644
--- a/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryTest.java
+++ b/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryTest.java
@@ -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 extends QueueEntryImplTestBase
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);
diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueEntryListTest.java b/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueEntryListTest.java
index c053957e2a..2c697cfe2b 100644
--- a/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueEntryListTest.java
+++ b/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueEntryListTest.java
@@ -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 extends QueueEntryListTestBase<StandardQ
}
@Override
- public ServerMessage getTestMessageToAdd() throws AMQException
+ public ServerMessage getTestMessageToAdd()
{
ServerMessage msg = mock(ServerMessage.class);
when(msg.getMessageNumber()).thenReturn(1l);
diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueTest.java b/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueTest.java
index 27fac12ac0..c7b812effe 100644
--- a/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueTest.java
+++ b/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueTest.java
@@ -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 SimpleAMQQueueTestBase<StandardQueueEntry
/**
* 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 SimpleAMQQueueTestBase<StandardQueueEntry
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 SimpleAMQQueueTestBase<StandardQueueEntry
* 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 SimpleAMQQueueTestBase<StandardQueueEntry
* @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));
+
+ // process queue
+ testQueue.processQueue(new QueueRunner(testQueue)
{
- // 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()
{
- public void run()
- {
- // do nothing
- }
- });
- }
- catch (AMQException e)
- {
- fail("Failure to process queue:" + e.getMessage());
- }
+ // do nothing
+ }
+ });
+
// wait up to 1 minute for message receipt
try
{
diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java b/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java
index d3ee938586..8b66e7d82f 100644
--- a/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java
+++ b/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java
@@ -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 AbstractDurableConfigurationStoreTestCase extends QpidTest
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 AbstractDurableConfigurationStoreTestCase extends QpidTest
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);
diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java b/java/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java
index b6300e6f48..224a22687f 100644
--- a/java/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java
+++ b/java/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java
@@ -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 extends QpidTestCase
_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 extends QpidTestCase
_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 extends QpidTestCase
_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 extends QpidTestCase
_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 extends QpidTestCase
_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 extends QpidTestCase
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
}
diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/store/TestableMemoryMessageStore.java b/java/broker-core/src/test/java/org/apache/qpid/server/store/TestableMemoryMessageStore.java
index 9dde7d26d0..6b9bb08aa9 100644
--- a/java/broker-core/src/test/java/org/apache/qpid/server/store/TestableMemoryMessageStore.java
+++ b/java/broker-core/src/test/java/org/apache/qpid/server/store/TestableMemoryMessageStore.java
@@ -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 extends TestMemoryMessageStore
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()
{
}
diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/txn/MockStoreTransaction.java b/java/broker-core/src/test/java/org/apache/qpid/server/txn/MockStoreTransaction.java
index 17955a8d52..ab18c8f41d 100644
--- a/java/broker-core/src/test/java/org/apache/qpid/server/txn/MockStoreTransaction.java
+++ b/java/broker-core/src/test/java/org/apache/qpid/server/txn/MockStoreTransaction.java
@@ -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 Transaction
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 Transaction
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;
}
diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java b/java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java
index ed1ea01108..fb63fefb88 100644
--- a/java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java
+++ b/java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java
@@ -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.actors.TestLogActor;
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.virtualhost.StandardVirtualHostFactory;
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());
diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java b/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java
index b71c6a92e6..223e2c5218 100644
--- a/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java
+++ b/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java
@@ -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 DurableConfigurationRecovererTest extends QpidTestCase
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()
{
diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java b/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java
index 832b89c81a..f7eecc73fc 100644
--- a/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java
+++ b/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java
@@ -23,7 +23,6 @@ package org.apache.qpid.server.virtualhost;
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 VirtualHost
}
@Override
- public int removeQueue(AMQQueue queue) throws AMQException
+ public int removeQueue(AMQQueue queue)
{
return 0;
}
@@ -160,7 +159,7 @@ public class MockVirtualHost implements VirtualHost
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 VirtualHost
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)
{
}
diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/StandardVirtualHostTest.java b/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/StandardVirtualHostTest.java
index f46349daa4..9dfd8833aa 100644
--- a/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/StandardVirtualHostTest.java
+++ b/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/StandardVirtualHostTest.java
@@ -38,6 +38,7 @@ import org.apache.qpid.server.security.SecurityManager;
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 extends QpidTestCase
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 extends QpidTestCase
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());
}
}
diff --git a/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ConsumerTarget_0_10.java b/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ConsumerTarget_0_10.java
index 114095bace..ff4bd1dc2e 100644
--- a/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ConsumerTarget_0_10.java
+++ b/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ConsumerTarget_0_10.java
@@ -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.ServerMessage;
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 AbstractConsumerTarget implements FlowC
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 AbstractConsumerTarget implements FlowC
_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 AbstractConsumerTarget implements FlowC
}
}
- public void flush() throws AMQException
+ public void flush()
{
flushCreditState(true);
getConsumer().flush();
diff --git a/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageConverter_v0_10.java b/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageConverter_v0_10.java
index 32ecc6bd0e..df4c398115 100644
--- a/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageConverter_v0_10.java
+++ b/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageConverter_v0_10.java
@@ -32,6 +32,8 @@ import org.apache.qpid.server.message.ServerMessage;
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 implements MessageConverter<ServerMessage, M
}
catch (IOException e)
{
- throw new RuntimeException(e);
+ throw new ConnectionScopedRuntimeException(e);
}
}
}
diff --git a/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageConverter_v0_10_to_Internal.java b/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageConverter_v0_10_to_Internal.java
index bc5f8899f2..68997bbb01 100644
--- a/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageConverter_v0_10_to_Internal.java
+++ b/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageConverter_v0_10_to_Internal.java
@@ -27,6 +27,7 @@ import org.apache.qpid.server.message.internal.InternalMessageMetaData;
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_Internal implements MessageConverter<Mess
}
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;
diff --git a/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerConnection.java b/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerConnection.java
index 66ffd1ef94..ff7ce0a79d 100644
--- a/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerConnection.java
+++ b/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerConnection.java
@@ -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.AMQSessionModel;
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.ExecutionException;
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 Connection implements AMQConnectionModel,
_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 Connection implements AMQConnectionModel,
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 Connection implements AMQConnectionModel,
return _actor;
}
- public void close(AMQConstant cause, String message) throws AMQException
+ public void close(AMQConstant cause, String message)
{
closeSubscriptions();
ConnectionCloseCode replyCode = ConnectionCloseCode.NORMAL;
diff --git a/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSession.java b/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSession.java
index 87a02b99c1..0e6b4d3b08 100644
--- a/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSession.java
+++ b/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSession.java
@@ -41,8 +41,7 @@ import java.util.concurrent.atomic.AtomicLong;
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 Session
_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 Session
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 Session
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 Session
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);
}
diff --git a/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegate.java b/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegate.java
index 9a90b74656..1bd50533ed 100644
--- a/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegate.java
+++ b/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegate.java
@@ -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.UUIDGenerator;
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.virtualhost.RequiredExchangeException;
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 extends SessionDelegate
{
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 extends SessionDelegate
{
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 extends SessionDelegate
}
else
{
-
- try
- {
- sub.flush();
- }
- catch (AMQException e)
- {
- exception(session, method, e, "Cannot flush subscription '" + destination);
- }
+ sub.flush();
}
}
@@ -566,9 +558,10 @@ public class ServerSessionDelegate extends SessionDelegate
{
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 extends SessionDelegate
{
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 extends SessionDelegate
{
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 extends SessionDelegate
+ " 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 extends SessionDelegate
}
- // 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 extends SessionDelegate
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 extends SessionDelegate
{
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 extends SessionDelegate
{
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 extends SessionDelegate
{
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 extends SessionDelegate
{
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 extends SessionDelegate
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 extends SessionDelegate
{
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 extends SessionDelegate
{
queue.clearQueue();
}
- catch (AMQException e)
+ catch (QpidSecurityException e)
{
- exception(session, method, e, "Cannot purge queue '" + queueName);
+ exception(session, method, ExecutionErrorCode.UNAUTHORIZED_ACCESS, e.getMessage());
}
}
}
diff --git a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java
index 8becdf853b..b15b3f0bfa 100644
--- a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java
+++ b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java
@@ -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.LocalTransaction;
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 AMQSessionModel, AsyncAutoCommitTransaction.F
_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 AMQSessionModel, AsyncAutoCommitTransaction.F
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 AMQSessionModel, AsyncAutoCommitTransaction.F
* @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 AMQSessionModel, AsyncAutoCommitTransaction.F
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 AMQSessionModel, AsyncAutoCommitTransaction.F
* 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 AMQSessionModel, AsyncAutoCommitTransaction.F
/**
* 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 AMQSessionModel, AsyncAutoCommitTransaction.F
{
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 AMQSessionModel, AsyncAutoCommitTransaction.F
* 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 AMQSessionModel, AsyncAutoCommitTransaction.F
*
* @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 AMQSessionModel, AsyncAutoCommitTransaction.F
@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 AMQSessionModel, AsyncAutoCommitTransaction.F
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 AMQSessionModel, AsyncAutoCommitTransaction.F
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);
}
diff --git a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngine.java b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngine.java
index e83e86981b..5e95701e5a 100644
--- a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngine.java
+++ b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngine.java
@@ -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.v0_8.state.AMQState;
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 implements ServerProtocolEngine, AMQProtocolSessi
}
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 implements ServerProtocolEngine, AMQProtocolSessi
}
}
- 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 implements ServerProtocolEngine, AMQProtocolSessi
}
catch (IOException e)
{
- throw new RuntimeException(e);
+ throw new ServerScopedRuntimeException(e);
}
final ByteBuffer buf;
@@ -628,12 +608,6 @@ public class AMQProtocolEngine implements ServerProtocolEngine, AMQProtocolSessi
_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 implements ServerProtocolEngine, AMQProtocolSessi
*
* @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 implements ServerProtocolEngine, AMQProtocolSessi
*
* @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 implements ServerProtocolEngine, AMQProtocolSessi
/** 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 implements ServerProtocolEngine, AMQProtocolSessi
}
}
- private void closeConnection(int channelId, AMQConnectionException e) throws AMQException
+ private void closeConnection(int channelId, AMQConnectionException e)
{
try
{
@@ -1039,7 +1012,7 @@ public class AMQProtocolEngine implements ServerProtocolEngine, AMQProtocolSessi
{
_stateManager.changeState(AMQState.CONNECTION_CLOSED);
}
- catch (AMQException e)
+ catch (ConnectionScopedRuntimeException e)
{
_logger.info(e.getMessage());
}
@@ -1240,9 +1213,9 @@ public class AMQProtocolEngine implements ServerProtocolEngine, AMQProtocolSessi
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 implements ServerProtocolEngine, AMQProtocolSessi
}
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 implements ServerProtocolEngine, AMQProtocolSessi
{
writeFrame(responseBody.generateFrame(0));
- try
- {
+ closeSession();
- closeSession();
- }
- catch (AMQException ex)
- {
- throw new RuntimeException(ex);
- }
}
finally
{
@@ -1489,15 +1470,7 @@ public class AMQProtocolEngine implements ServerProtocolEngine, AMQProtocolSessi
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 implements ServerProtocolEngine, AMQProtocolSessi
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 implements ServerProtocolEngine, AMQProtocolSessi
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 implements ServerProtocolEngine, AMQProtocolSessi
@Override
public void deliverToClient(final Consumer sub, final ServerMessage message,
final InstanceProperties props, final long deliveryTag)
- throws AMQException
{
registerMessageDelivered(message.getSize());
_protocolOutputConverter.writeDeliver(message,
diff --git a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolSession.java b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolSession.java
index 6bcd4b9d49..58a3b5df12 100644
--- a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolSession.java
+++ b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolSession.java
@@ -71,7 +71,7 @@ public interface AMQProtocolSession extends AMQVersionAwareProtocolSession, Auth
public static interface Task
{
- public void doTask(AMQProtocolSession session) throws AMQException;
+ public void doTask(AMQProtocolSession session);
}
/**
@@ -152,7 +152,7 @@ public interface AMQProtocolSession extends AMQVersionAwareProtocolSession, Auth
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();
diff --git a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/ClientDeliveryMethod.java b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/ClientDeliveryMethod.java
index 2e362c11f8..9f8799f68e 100644
--- a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/ClientDeliveryMethod.java
+++ b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/ClientDeliveryMethod.java
@@ -28,5 +28,5 @@ import org.apache.qpid.server.consumer.Consumer;
public interface ClientDeliveryMethod
{
void deliverToClient(final Consumer sub, final ServerMessage message, final InstanceProperties props,
- final long deliveryTag) throws AMQException;
+ final long deliveryTag);
}
diff --git a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/ConsumerTarget_0_8.java b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/ConsumerTarget_0_8.java
index 0f0e49bf7f..2ce8caefc9 100644
--- a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/ConsumerTarget_0_8.java
+++ b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/ConsumerTarget_0_8.java
@@ -114,7 +114,7 @@ public abstract class ConsumerTarget_0_8 extends AbstractConsumerTarget implemen
* @throws org.apache.qpid.AMQException
*/
@Override
- public void send(MessageInstance entry, boolean batch) throws AMQException
+ public void send(MessageInstance entry, boolean batch)
{
// We don't decrement the reference here as we don't want to consume the message
// but we do want to send it to the client.
@@ -177,7 +177,7 @@ public abstract class ConsumerTarget_0_8 extends AbstractConsumerTarget implemen
* @throws org.apache.qpid.AMQException
*/
@Override
- public void send(MessageInstance entry, boolean batch) throws AMQException
+ public void send(MessageInstance entry, boolean batch)
{
// if we do not need to wait for client acknowledgements
// we can decrement the reference count immediately.
@@ -293,7 +293,7 @@ public abstract class ConsumerTarget_0_8 extends AbstractConsumerTarget implemen
* @throws org.apache.qpid.AMQException
*/
@Override
- public void send(MessageInstance entry, boolean batch) throws AMQException
+ public void send(MessageInstance entry, boolean batch)
{
@@ -505,7 +505,6 @@ public abstract class ConsumerTarget_0_8 extends AbstractConsumerTarget implemen
}
protected void sendToClient(final ServerMessage message, final InstanceProperties props, final long deliveryTag)
- throws AMQException
{
_deliveryMethod.deliverToClient(getConsumer(), message, props, deliveryTag);
@@ -524,7 +523,7 @@ public abstract class ConsumerTarget_0_8 extends AbstractConsumerTarget implemen
converter.confirmConsumerAutoClose(getChannel().getChannelId(), getConsumerTag());
}
- public void queueEmpty() throws AMQException
+ public void queueEmpty()
{
if (isAutoClose())
{
diff --git a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/MessageConverter_Internal_to_v0_8.java b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/MessageConverter_Internal_to_v0_8.java
index b80ad3e7b8..f2bb95c8d5 100644
--- a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/MessageConverter_Internal_to_v0_8.java
+++ b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/MessageConverter_Internal_to_v0_8.java
@@ -29,6 +29,7 @@ import org.apache.qpid.server.message.internal.InternalMessage;
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.codec.BBEncoder;
@@ -236,7 +237,7 @@ public class MessageConverter_Internal_to_v0_8 implements MessageConverter<Inter
}
catch (IOException e)
{
- throw new RuntimeException(e);
+ throw new ConnectionScopedRuntimeException(e);
}
}
}
diff --git a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/MessageConverter_v0_8_to_Internal.java b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/MessageConverter_v0_8_to_Internal.java
index 6076ff66c7..f35d37ecbd 100644
--- a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/MessageConverter_v0_8_to_Internal.java
+++ b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/MessageConverter_v0_8_to_Internal.java
@@ -22,6 +22,7 @@ package org.apache.qpid.server.protocol.v0_8;
import org.apache.qpid.server.message.internal.InternalMessage;
import org.apache.qpid.server.plugin.MessageConverter;
+import org.apache.qpid.server.util.ConnectionScopedRuntimeException;
import org.apache.qpid.server.virtualhost.VirtualHost;
import org.apache.qpid.transport.codec.BBDecoder;
import org.apache.qpid.typedmessage.TypedBytesContentReader;
@@ -124,11 +125,11 @@ public class MessageConverter_v0_8_to_Internal implements MessageConverter<AMQMe
}
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);
}
}
return list;
diff --git a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/MessageMetaData.java b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/MessageMetaData.java
index 3665e7f135..fd7fb9ca80 100644
--- a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/MessageMetaData.java
+++ b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/MessageMetaData.java
@@ -22,6 +22,8 @@ package org.apache.qpid.server.protocol.v0_8;
import java.util.Collection;
import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQFrameDecodingException;
+import org.apache.qpid.framing.AMQProtocolVersionException;
import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.framing.BasicContentHeaderProperties;
import org.apache.qpid.framing.ContentHeaderBody;
@@ -32,6 +34,7 @@ import org.apache.qpid.server.message.AMQMessageHeader;
import org.apache.qpid.server.plugin.MessageMetaDataType;
import org.apache.qpid.server.store.StorableMessageMetaData;
import org.apache.qpid.server.util.ByteBufferOutputStream;
+import org.apache.qpid.server.util.ConnectionScopedRuntimeException;
import org.apache.qpid.util.ByteBufferInputStream;
import java.io.DataInputStream;
@@ -132,7 +135,7 @@ public class MessageMetaData implements StorableMessageMetaData
catch (IOException e)
{
// This shouldn't happen as we are not actually using anything that can throw an IO Exception
- throw new RuntimeException(e);
+ throw new ConnectionScopedRuntimeException(e);
}
return dest.position()-oldPosition;
@@ -196,17 +199,21 @@ public class MessageMetaData implements StorableMessageMetaData
};
return new MessageMetaData(publishBody, chb, arrivalTime);
}
- catch (AMQException e)
+ catch (IOException e)
{
- throw new RuntimeException(e);
+ throw new ConnectionScopedRuntimeException(e);
}
- catch (IOException e)
+ catch (AMQProtocolVersionException e)
{
- throw new RuntimeException(e);
+ throw new ConnectionScopedRuntimeException(e);
+ }
+ catch (AMQFrameDecodingException e)
+ {
+ throw new ConnectionScopedRuntimeException(e);
}
}
- };
+ }
public AMQMessageHeader getMessageHeader()
{
diff --git a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicConsumeMethodHandler.java b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicConsumeMethodHandler.java
index b28bb5a0ad..ce90de7aac 100644
--- a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicConsumeMethodHandler.java
+++ b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicConsumeMethodHandler.java
@@ -28,6 +28,7 @@ import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.framing.BasicConsumeBody;
import org.apache.qpid.framing.MethodRegistry;
import org.apache.qpid.protocol.AMQConstant;
+import org.apache.qpid.server.filter.AMQInvalidArgumentException;
import org.apache.qpid.server.message.MessageSource;
import org.apache.qpid.server.protocol.v0_8.AMQChannel;
import org.apache.qpid.server.protocol.v0_8.AMQProtocolSession;
@@ -35,6 +36,7 @@ import org.apache.qpid.server.protocol.AMQSessionModel;
import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.protocol.v0_8.state.AMQStateManager;
import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener;
+import org.apache.qpid.server.security.QpidSecurityException;
import org.apache.qpid.server.virtualhost.VirtualHost;
public class BasicConsumeMethodHandler implements StateAwareMethodListener<BasicConsumeBody>
@@ -148,7 +150,7 @@ public class BasicConsumeMethodHandler implements StateAwareMethodListener<Basic
}
}
- catch (org.apache.qpid.AMQInvalidArgumentException ise)
+ catch (AMQInvalidArgumentException ise)
{
_logger.debug("Closing connection due to invalid selector");
@@ -175,6 +177,13 @@ public class BasicConsumeMethodHandler implements StateAwareMethodListener<Basic
+ queue.getName()
+ " exclusively as it already has a consumer");
}
+ catch (QpidSecurityException e)
+ {
+ throw body.getChannelException(AMQConstant.ACCESS_REFUSED,
+ "Cannot subscribe to queue "
+ + queue.getName()
+ + " permission denied");
+ }
}
}
diff --git a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicGetMethodHandler.java b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicGetMethodHandler.java
index b1d2fa5088..c9a7cc69a1 100644
--- a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicGetMethodHandler.java
+++ b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicGetMethodHandler.java
@@ -31,6 +31,7 @@ import org.apache.qpid.framing.MethodRegistry;
import org.apache.qpid.protocol.AMQConstant;
import org.apache.qpid.server.message.InstanceProperties;
import org.apache.qpid.server.message.MessageInstance;
+import org.apache.qpid.server.message.MessageSource;
import org.apache.qpid.server.message.ServerMessage;
import org.apache.qpid.server.protocol.v0_8.AMQChannel;
import org.apache.qpid.server.flow.FlowCreditManager;
@@ -45,6 +46,7 @@ import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener;
import org.apache.qpid.server.protocol.v0_8.ClientDeliveryMethod;
import org.apache.qpid.server.protocol.v0_8.RecordDeliveryMethod;
import org.apache.qpid.server.consumer.Consumer;
+import org.apache.qpid.server.security.QpidSecurityException;
import org.apache.qpid.server.virtualhost.VirtualHost;
import java.util.EnumSet;
@@ -106,14 +108,33 @@ public class BasicGetMethodHandler implements StateAwareMethodListener<BasicGetB
}
}
- if (!performGet(queue,protocolConnection, channel, !body.getNoAck()))
+ try
{
- MethodRegistry methodRegistry = protocolConnection.getMethodRegistry();
- // TODO - set clusterId
- BasicGetEmptyBody responseBody = methodRegistry.createBasicGetEmptyBody(null);
+ if (!performGet(queue,protocolConnection, channel, !body.getNoAck()))
+ {
+ MethodRegistry methodRegistry = protocolConnection.getMethodRegistry();
+ // TODO - set clusterId
+ BasicGetEmptyBody responseBody = methodRegistry.createBasicGetEmptyBody(null);
- protocolConnection.writeFrame(responseBody.generateFrame(channelId));
+ protocolConnection.writeFrame(responseBody.generateFrame(channelId));
+ }
+ }
+ catch (QpidSecurityException e)
+ {
+ throw body.getConnectionException(AMQConstant.ACCESS_REFUSED,
+ e.getMessage());
+ }
+ catch (MessageSource.ExistingExclusiveConsumer e)
+ {
+ throw body.getConnectionException(AMQConstant.NOT_ALLOWED,
+ "Queue has an exclusive consumer");
+ }
+ catch (MessageSource.ExistingConsumerPreventsExclusive e)
+ {
+ throw body.getConnectionException(AMQConstant.INTERNAL_ERROR,
+ "The GET request has been evaluated as an exclusive consumer, " +
+ "this is likely due to a programming error in the Qpid broker");
}
}
}
@@ -123,7 +144,8 @@ public class BasicGetMethodHandler implements StateAwareMethodListener<BasicGetB
final AMQProtocolSession session,
final AMQChannel channel,
final boolean acks)
- throws AMQException
+ throws AMQException, QpidSecurityException, MessageSource.ExistingConsumerPreventsExclusive,
+ MessageSource.ExistingExclusiveConsumer
{
final FlowCreditManager singleMessageCredit = new MessageOnlyCreditManager(1L);
@@ -186,7 +208,7 @@ public class BasicGetMethodHandler implements StateAwareMethodListener<BasicGetB
@Override
public void deliverToClient(final Consumer sub, final ServerMessage message,
- final InstanceProperties props, final long deliveryTag) throws AMQException
+ final InstanceProperties props, final long deliveryTag)
{
_singleMessageCredit.useCreditForMessage(message.getSize());
_session.getProtocolOutputConverter().writeGetOk(message,
diff --git a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicPublishMethodHandler.java b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicPublishMethodHandler.java
index f8a7722447..318efdd125 100644
--- a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicPublishMethodHandler.java
+++ b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicPublishMethodHandler.java
@@ -34,6 +34,7 @@ import org.apache.qpid.server.exchange.Exchange;
import org.apache.qpid.server.protocol.v0_8.AMQProtocolSession;
import org.apache.qpid.server.protocol.v0_8.state.AMQStateManager;
import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener;
+import org.apache.qpid.server.security.QpidSecurityException;
import org.apache.qpid.server.virtualhost.VirtualHost;
public class BasicPublishMethodHandler implements StateAwareMethodListener<BasicPublishBody>
@@ -88,7 +89,14 @@ public class BasicPublishMethodHandler implements StateAwareMethodListener<Basic
MessagePublishInfo info = session.getMethodRegistry().getProtocolVersionMethodConverter().convertToInfo(body);
info.setExchange(exchangeName);
- channel.setPublishFrame(info, exch);
+ try
+ {
+ channel.setPublishFrame(info, exch);
+ }
+ catch (QpidSecurityException e)
+ {
+ throw body.getConnectionException(AMQConstant.ACCESS_REFUSED, e.getMessage());
+ }
}
}
diff --git a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ChannelOpenHandler.java b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ChannelOpenHandler.java
index 442c912032..2594242db4 100644
--- a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ChannelOpenHandler.java
+++ b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ChannelOpenHandler.java
@@ -35,6 +35,7 @@ import org.apache.qpid.server.protocol.v0_8.AMQChannel;
import org.apache.qpid.server.protocol.v0_8.AMQProtocolSession;
import org.apache.qpid.server.protocol.v0_8.state.AMQStateManager;
import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener;
+import org.apache.qpid.server.util.ConnectionScopedRuntimeException;
import org.apache.qpid.server.virtualhost.VirtualHost;
import java.io.ByteArrayOutputStream;
@@ -99,7 +100,7 @@ public class ChannelOpenHandler implements StateAwareMethodListener<ChannelOpenB
catch (IOException e)
{
// This *really* shouldn't happen as we're not doing any I/O
- throw new RuntimeException("I/O exception when writing to byte array", e);
+ throw new ConnectionScopedRuntimeException("I/O exception when writing to byte array", e);
}
// should really associate this channelId to the session
@@ -123,7 +124,7 @@ public class ChannelOpenHandler implements StateAwareMethodListener<ChannelOpenB
catch (IOException e)
{
// This *really* shouldn't happen as we're not doing any I/O
- throw new RuntimeException("I/O exception when writing to byte array", e);
+ throw new ConnectionScopedRuntimeException("I/O exception when writing to byte array", e);
}
// should really associate this channelId to the session
diff --git a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeclareHandler.java b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeclareHandler.java
index 154c38a4bf..5c5b1f141b 100644
--- a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeclareHandler.java
+++ b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeclareHandler.java
@@ -24,7 +24,7 @@ import org.apache.log4j.Logger;
import org.apache.qpid.AMQConnectionException;
import org.apache.qpid.AMQException;
-import org.apache.qpid.AMQUnknownExchangeType;
+import org.apache.qpid.server.exchange.AMQUnknownExchangeType;
import org.apache.qpid.framing.AMQMethodBody;
import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.framing.ExchangeDeclareBody;
@@ -35,8 +35,10 @@ import org.apache.qpid.server.exchange.Exchange;
import org.apache.qpid.server.protocol.v0_8.AMQProtocolSession;
import org.apache.qpid.server.protocol.v0_8.state.AMQStateManager;
import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener;
+import org.apache.qpid.server.security.QpidSecurityException;
import org.apache.qpid.server.virtualhost.ExchangeExistsException;
import org.apache.qpid.server.virtualhost.ReservedExchangeNameException;
+import org.apache.qpid.server.virtualhost.UnknownExchangeException;
import org.apache.qpid.server.virtualhost.VirtualHost;
public class ExchangeDeclareHandler implements StateAwareMethodListener<ExchangeDeclareBody>
@@ -124,6 +126,15 @@ public class ExchangeDeclareHandler implements StateAwareMethodListener<Exchange
{
throw body.getConnectionException(AMQConstant.COMMAND_INVALID, "Unknown exchange: " + exchangeName,e);
}
+ catch (QpidSecurityException e)
+ {
+ throw body.getConnectionException(AMQConstant.ACCESS_REFUSED, e.getMessage());
+ }
+ catch (UnknownExchangeException e)
+ {
+ // note - since 0-8/9/9-1 can't set the alt. exchange this exception should never occur
+ throw body.getConnectionException(AMQConstant.NOT_FOUND, "Unknown alternate exchange",e);
+ }
}
diff --git a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeleteHandler.java b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeleteHandler.java
index 75f749fe9a..ea3d7ded4d 100644
--- a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeleteHandler.java
+++ b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeleteHandler.java
@@ -26,10 +26,10 @@ import org.apache.qpid.framing.ExchangeDeleteOkBody;
import org.apache.qpid.protocol.AMQConstant;
import org.apache.qpid.server.protocol.v0_8.AMQChannel;
import org.apache.qpid.server.exchange.Exchange;
-import org.apache.qpid.server.exchange.ExchangeInUseException;
import org.apache.qpid.server.protocol.v0_8.AMQProtocolSession;
import org.apache.qpid.server.protocol.v0_8.state.AMQStateManager;
import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener;
+import org.apache.qpid.server.security.QpidSecurityException;
import org.apache.qpid.server.virtualhost.ExchangeIsAlternateException;
import org.apache.qpid.server.virtualhost.RequiredExchangeException;
import org.apache.qpid.server.virtualhost.VirtualHost;
@@ -73,11 +73,6 @@ public class ExchangeDeleteHandler implements StateAwareMethodListener<ExchangeD
session.writeFrame(responseBody.generateFrame(channelId));
}
- catch (ExchangeInUseException e)
- {
- throw body.getChannelException(AMQConstant.IN_USE, "Exchange in use");
- // TODO: sort out consistent channel close mechanism that does all clean up etc.
- }
catch (ExchangeIsAlternateException e)
{
@@ -88,5 +83,9 @@ public class ExchangeDeleteHandler implements StateAwareMethodListener<ExchangeD
{
throw body.getChannelException(AMQConstant.NOT_ALLOWED, "Exchange '"+body.getExchange()+"' cannot be deleted");
}
+ catch (QpidSecurityException e)
+ {
+ throw body.getConnectionException(AMQConstant.ACCESS_REFUSED, e.getMessage());
+ }
}
}
diff --git a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueBindHandler.java b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueBindHandler.java
index d95d59f75f..401718db88 100644
--- a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueBindHandler.java
+++ b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueBindHandler.java
@@ -41,6 +41,7 @@ import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.queue.QueueRegistry;
import org.apache.qpid.server.protocol.v0_8.state.AMQStateManager;
import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener;
+import org.apache.qpid.server.security.QpidSecurityException;
import org.apache.qpid.server.virtualhost.VirtualHost;
import java.util.Map;
@@ -147,6 +148,10 @@ public class QueueBindHandler implements StateAwareMethodListener<QueueBindBody>
{
throw body.getChannelException(AMQConstant.CHANNEL_ERROR, e.toString());
}
+ catch (QpidSecurityException e)
+ {
+ throw body.getConnectionException(AMQConstant.ACCESS_REFUSED, e.getMessage());
+ }
if (_log.isInfoEnabled())
{
diff --git a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueDeclareHandler.java b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueDeclareHandler.java
index 263175d590..5b5525643c 100644
--- a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueDeclareHandler.java
+++ b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueDeclareHandler.java
@@ -34,19 +34,17 @@ import org.apache.qpid.server.model.UUIDGenerator;
import org.apache.qpid.server.protocol.v0_8.AMQProtocolSession;
import org.apache.qpid.server.protocol.AMQSessionModel;
import org.apache.qpid.server.queue.AMQQueue;
-import org.apache.qpid.server.queue.AMQQueueFactory;
import org.apache.qpid.server.queue.QueueArgumentsConverter;
-import org.apache.qpid.server.queue.QueueRegistry;
import org.apache.qpid.server.protocol.v0_8.state.AMQStateManager;
import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener;
-import org.apache.qpid.server.store.DurableConfigurationStoreHelper;
-import org.apache.qpid.server.store.DurableConfigurationStore;
+import org.apache.qpid.server.security.QpidSecurityException;
import org.apache.qpid.server.util.Action;
+import org.apache.qpid.server.util.ConnectionScopedRuntimeException;
import org.apache.qpid.server.virtualhost.VirtualHost;
import java.util.Map;
import java.util.UUID;
-import org.apache.qpid.server.virtualhost.plugins.QueueExistsException;
+import org.apache.qpid.server.virtualhost.QueueExistsException;
public class QueueDeclareHandler implements StateAwareMethodListener<QueueDeclareBody>
{
@@ -129,7 +127,7 @@ public class QueueDeclareHandler implements StateAwareMethodListener<QueueDeclar
final AMQQueue q = queue;
final AMQProtocolSession.Task sessionCloseTask = new AMQProtocolSession.Task()
{
- public void doTask(AMQProtocolSession session) throws AMQException
+ public void doTask(AMQProtocolSession session)
{
q.setExclusiveOwningSession(null);
}
@@ -185,6 +183,10 @@ public class QueueDeclareHandler implements StateAwareMethodListener<QueueDeclar
}
}
+ catch (QpidSecurityException e)
+ {
+ throw body.getConnectionException(AMQConstant.ACCESS_REFUSED, e.getMessage());
+ }
//set this as the default queue on the channel:
channel.setDefaultQueue(queue);
@@ -213,7 +215,7 @@ public class QueueDeclareHandler implements StateAwareMethodListener<QueueDeclar
QueueDeclareBody body,
final VirtualHost virtualHost,
final AMQProtocolSession session)
- throws AMQException
+ throws AMQException, QpidSecurityException, QueueExistsException
{
final boolean durable = body.getDurable();
@@ -235,11 +237,18 @@ public class QueueDeclareHandler implements StateAwareMethodListener<QueueDeclar
final AMQProtocolSession.Task deleteQueueTask =
new AMQProtocolSession.Task()
{
- public void doTask(AMQProtocolSession session) throws AMQException
+ public void doTask(AMQProtocolSession session)
{
if (virtualHost.getQueue(queueName.toString()) == queue)
{
- virtualHost.removeQueue(queue);
+ try
+ {
+ virtualHost.removeQueue(queue);
+ }
+ catch (QpidSecurityException e)
+ {
+ throw new ConnectionScopedRuntimeException("Permission exception: Unable to remove a temporary queue created by a session which has now removed itself", e);
+ }
}
}
};
diff --git a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueDeleteHandler.java b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueDeleteHandler.java
index d3c196a789..3a9a6dc44e 100644
--- a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueDeleteHandler.java
+++ b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueDeleteHandler.java
@@ -32,6 +32,7 @@ import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.queue.QueueRegistry;
import org.apache.qpid.server.protocol.v0_8.state.AMQStateManager;
import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener;
+import org.apache.qpid.server.security.QpidSecurityException;
import org.apache.qpid.server.store.DurableConfigurationStore;
import org.apache.qpid.server.store.DurableConfigurationStoreHelper;
import org.apache.qpid.server.virtualhost.VirtualHost;
@@ -111,7 +112,15 @@ public class QueueDeleteHandler implements StateAwareMethodListener<QueueDeleteB
"Queue " + queue.getName() + " is exclusive, but not created on this Connection.");
}
- int purged = virtualHost.removeQueue(queue);
+ int purged = 0;
+ try
+ {
+ purged = virtualHost.removeQueue(queue);
+ }
+ catch (QpidSecurityException e)
+ {
+ throw body.getConnectionException(AMQConstant.ACCESS_REFUSED, e.getMessage());
+ }
MethodRegistry methodRegistry = protocolConnection.getMethodRegistry();
QueueDeleteOkBody responseBody = methodRegistry.createQueueDeleteOkBody(purged);
diff --git a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueuePurgeHandler.java b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueuePurgeHandler.java
index ff845d3c16..6d8f8e64fc 100644
--- a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueuePurgeHandler.java
+++ b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueuePurgeHandler.java
@@ -33,6 +33,7 @@ import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.queue.QueueRegistry;
import org.apache.qpid.server.protocol.v0_8.state.AMQStateManager;
import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener;
+import org.apache.qpid.server.security.QpidSecurityException;
import org.apache.qpid.server.virtualhost.VirtualHost;
public class QueuePurgeHandler implements StateAwareMethodListener<QueuePurgeBody>
@@ -103,10 +104,18 @@ public class QueuePurgeHandler implements StateAwareMethodListener<QueuePurgeBod
"Queue is exclusive, but not created on this Connection.");
}
- long purged = queue.clearQueue();
+ long purged = 0;
+ try
+ {
+ purged = queue.clearQueue();
+ }
+ catch (QpidSecurityException e)
+ {
+ throw body.getConnectionException(AMQConstant.ACCESS_REFUSED, e.getMessage());
+ }
- if(!body.getNowait())
+ if(!body.getNowait())
{
channel.sync();
MethodRegistry methodRegistry = protocolConnection.getMethodRegistry();
diff --git a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueUnbindHandler.java b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueUnbindHandler.java
index d568e0f581..91025dacf2 100644
--- a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueUnbindHandler.java
+++ b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueUnbindHandler.java
@@ -38,6 +38,7 @@ import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.queue.QueueRegistry;
import org.apache.qpid.server.protocol.v0_8.state.AMQStateManager;
import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener;
+import org.apache.qpid.server.security.QpidSecurityException;
import org.apache.qpid.server.virtualhost.VirtualHost;
public class QueueUnbindHandler implements StateAwareMethodListener<QueueUnbindBody>
@@ -105,7 +106,14 @@ public class QueueUnbindHandler implements StateAwareMethodListener<QueueUnbindB
}
else
{
- exch.removeBinding(String.valueOf(routingKey), queue, FieldTable.convertToMap(body.getArguments()));
+ try
+ {
+ exch.removeBinding(String.valueOf(routingKey), queue, FieldTable.convertToMap(body.getArguments()));
+ }
+ catch (QpidSecurityException e)
+ {
+ throw body.getConnectionException(AMQConstant.ACCESS_REFUSED, e.getMessage());
+ }
}
diff --git a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/output/ProtocolOutputConverter.java b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/output/ProtocolOutputConverter.java
index 1e69edba91..7678ce812b 100644
--- a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/output/ProtocolOutputConverter.java
+++ b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/output/ProtocolOutputConverter.java
@@ -49,21 +49,19 @@ public interface ProtocolOutputConverter
void writeDeliver(final ServerMessage msg,
final InstanceProperties props, int channelId,
long deliveryTag,
- AMQShortString consumerTag)
- throws AMQException;
+ AMQShortString consumerTag);
void writeGetOk(final ServerMessage msg,
final InstanceProperties props,
int channelId,
long deliveryTag,
- int queueSize) throws AMQException;
+ int queueSize);
byte getProtocolMinorVersion();
byte getProtocolMajorVersion();
- void writeReturn(MessagePublishInfo messagePublishInfo, ContentHeaderBody header, MessageContentSource msgContent, int channelId, int replyCode, AMQShortString replyText)
- throws AMQException;
+ void writeReturn(MessagePublishInfo messagePublishInfo, ContentHeaderBody header, MessageContentSource msgContent, int channelId, int replyCode, AMQShortString replyText);
void writeFrame(AMQDataBlock block);
}
diff --git a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/output/ProtocolOutputConverterImpl.java b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/output/ProtocolOutputConverterImpl.java
index 290a859df6..f786cb113a 100644
--- a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/output/ProtocolOutputConverterImpl.java
+++ b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/output/ProtocolOutputConverterImpl.java
@@ -68,7 +68,6 @@ class ProtocolOutputConverterImpl implements ProtocolOutputConverter
final InstanceProperties props, int channelId,
long deliveryTag,
AMQShortString consumerTag)
- throws AMQException
{
final AMQMessage msg = convertToAMQMessage(m);
final boolean isRedelivered = Boolean.TRUE.equals(props.getProperty(InstanceProperties.Property.REDELIVERED));
@@ -95,13 +94,11 @@ class ProtocolOutputConverterImpl implements ProtocolOutputConverter
}
private void writeMessageDelivery(AMQMessage message, int channelId, AMQBody deliverBody)
- throws AMQException
{
writeMessageDelivery(message, message.getContentHeaderBody(), channelId, deliverBody);
}
private void writeMessageDelivery(MessageContentSource message, ContentHeaderBody contentHeaderBody, int channelId, AMQBody deliverBody)
- throws AMQException
{
@@ -193,7 +190,7 @@ class ProtocolOutputConverterImpl implements ProtocolOutputConverter
final InstanceProperties props,
int channelId,
long deliveryTag,
- int queueSize) throws AMQException
+ int queueSize)
{
AMQBody deliver = createEncodedGetOkBody(msg, props, deliveryTag, queueSize);
writeMessageDelivery(convertToAMQMessage(msg), channelId, deliver);
@@ -204,7 +201,6 @@ class ProtocolOutputConverterImpl implements ProtocolOutputConverter
boolean isRedelivered,
final long deliveryTag,
final AMQShortString consumerTag)
- throws AMQException
{
final AMQShortString exchangeName;
@@ -282,7 +278,6 @@ class ProtocolOutputConverterImpl implements ProtocolOutputConverter
}
private AMQBody createEncodedGetOkBody(ServerMessage msg, InstanceProperties props, long deliveryTag, int queueSize)
- throws AMQException
{
final AMQShortString exchangeName;
final AMQShortString routingKey;
@@ -316,7 +311,7 @@ class ProtocolOutputConverterImpl implements ProtocolOutputConverter
private AMQBody createEncodedReturnFrame(MessagePublishInfo messagePublishInfo,
int replyCode,
- AMQShortString replyText) throws AMQException
+ AMQShortString replyText)
{
BasicReturnBody basicReturnBody =
@@ -330,7 +325,6 @@ class ProtocolOutputConverterImpl implements ProtocolOutputConverter
}
public void writeReturn(MessagePublishInfo messagePublishInfo, ContentHeaderBody header, MessageContentSource message, int channelId, int replyCode, AMQShortString replyText)
- throws AMQException
{
AMQBody returnFrame = createEncodedReturnFrame(messagePublishInfo, replyCode, replyText);
diff --git a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/state/AMQStateManager.java b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/state/AMQStateManager.java
index 0555bba98b..c3cbb5e26f 100644
--- a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/state/AMQStateManager.java
+++ b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/state/AMQStateManager.java
@@ -52,8 +52,6 @@ public class AMQStateManager implements AMQMethodListener
/** The current state */
private AMQState _currentState;
- private CopyOnWriteArraySet<StateListener> _stateListeners = new CopyOnWriteArraySet<StateListener>();
-
public AMQStateManager(Broker broker, AMQProtocolSession protocolSession)
{
_broker = broker;
@@ -72,30 +70,17 @@ public class AMQStateManager implements AMQMethodListener
return _broker;
}
- public AMQState getCurrentState()
- {
- return _currentState;
- }
-
- public void changeState(AMQState newState) throws AMQException
+ public void changeState(AMQState newState)
{
_logger.debug("State changing to " + newState + " from old state " + _currentState);
final AMQState oldState = _currentState;
_currentState = newState;
- for (StateListener l : _stateListeners)
- {
- l.stateChanged(oldState, newState);
- }
}
public void error(Exception e)
{
_logger.error("State manager received error notification[Current State:" + _currentState + "]: " + e, e);
- for (StateListener l : _stateListeners)
- {
- l.error(e);
- }
}
public <B extends AMQMethodBody> boolean methodReceived(AMQMethodEvent<B> evt) throws AMQException
@@ -121,28 +106,6 @@ public class AMQStateManager implements AMQMethodListener
}
- private <B extends AMQMethodBody> void checkChannel(AMQMethodEvent<B> evt, AMQProtocolSession protocolSession)
- throws AMQException
- {
- if ((evt.getChannelId() != 0) && !(evt.getMethod() instanceof ChannelOpenBody)
- && (protocolSession.getChannel(evt.getChannelId()) == null)
- && !protocolSession.channelAwaitingClosure(evt.getChannelId()))
- {
- throw evt.getMethod().getChannelNotFoundException(evt.getChannelId());
- }
- }
-
- public void addStateListener(StateListener listener)
- {
- _logger.debug("Adding state listener");
- _stateListeners.add(listener);
- }
-
- public void removeStateListener(StateListener listener)
- {
- _stateListeners.remove(listener);
- }
-
public VirtualHostRegistry getVirtualHostRegistry()
{
return _broker.getVirtualHostRegistry();
diff --git a/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AMQChannelTest.java b/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AMQChannelTest.java
index b358c7c5c5..317a544b6c 100644
--- a/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AMQChannelTest.java
+++ b/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AMQChannelTest.java
@@ -61,7 +61,7 @@ public class AMQChannelTest extends QpidTestCase
MessageContentSource msgContent,
int channelId,
int replyCode,
- AMQShortString replyText) throws AMQException
+ AMQShortString replyText)
{
_replies.put(replyCode, replyText.asString());
}
diff --git a/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AckTest.java b/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AckTest.java
index c805956b83..8d7de4cd93 100644
--- a/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AckTest.java
+++ b/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AckTest.java
@@ -139,28 +139,20 @@ public class AckTest extends QpidTestCase
final StoredMessage storedMessage = _messageStore.addMessage(mmd);
final AMQMessage message = new AMQMessage(storedMessage);
ServerTransaction txn = new AutoCommitTransaction(_messageStore);
- txn.enqueue(_queue, message, new ServerTransaction.Action() {
- public void postCommit()
- {
- try
- {
-
- _queue.enqueue(message,null);
- }
- catch (AMQException e)
- {
- throw new RuntimeException(e);
- }
- }
-
- public void onRollback()
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
- });
+ txn.enqueue(_queue, message,
+ new ServerTransaction.Action()
+ {
+ public void postCommit()
+ {
+ _queue.enqueue(message,null);
+ }
+
+ public void onRollback()
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+ });
- // we manually send the message to the subscription
- //_subscription.send(new QueueEntry(_queue,msg), _queue);
}
try
{
@@ -177,7 +169,7 @@ public class AckTest extends QpidTestCase
* Tests that the acknowledgements are correctly associated with a channel and
* order is preserved when acks are enabled
*/
- public void testAckChannelAssociationTest() throws AMQException
+ public void testAckChannelAssociationTest() throws Exception
{
_subscriptionTarget = ConsumerTarget_0_8.createAckTarget(_channel,
DEFAULT_CONSUMER_TAG,
@@ -206,7 +198,7 @@ public class AckTest extends QpidTestCase
/**
* Tests that in no-ack mode no messages are retained
*/
- public void testNoAckMode() throws AMQException
+ public void testNoAckMode() throws Exception
{
// false arg means no acks expected
_subscriptionTarget = ConsumerTarget_0_8.createNoAckTarget(_channel,
@@ -231,7 +223,7 @@ public class AckTest extends QpidTestCase
/**
* Tests that in no-ack mode no messages are retained
*/
- public void testPersistentNoAckMode() throws AMQException
+ public void testPersistentNoAckMode() throws Exception
{
// false arg means no acks expected
@@ -255,7 +247,7 @@ public class AckTest extends QpidTestCase
* Tests that a single acknowledgement is handled correctly (i.e multiple flag not
* set case)
*/
- public void testSingleAckReceivedTest() throws AMQException
+ public void testSingleAckReceivedTest() throws Exception
{
_subscriptionTarget = ConsumerTarget_0_8.createAckTarget(_channel,
@@ -292,7 +284,7 @@ public class AckTest extends QpidTestCase
* Tests that a single acknowledgement is handled correctly (i.e multiple flag not
* set case)
*/
- public void testMultiAckReceivedTest() throws AMQException
+ public void testMultiAckReceivedTest() throws Exception
{
_subscriptionTarget = ConsumerTarget_0_8.createAckTarget(_channel,
@@ -326,7 +318,7 @@ public class AckTest extends QpidTestCase
/**
* Tests that a multiple acknowledgement is handled correctly. When ack'ing all pending msgs.
*/
- public void testMultiAckAllReceivedTest() throws AMQException
+ public void testMultiAckAllReceivedTest() throws Exception
{
_subscriptionTarget = ConsumerTarget_0_8.createAckTarget(_channel,
diff --git a/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AcknowledgeTest.java b/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AcknowledgeTest.java
index f47525097e..9e551c9c01 100644
--- a/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AcknowledgeTest.java
+++ b/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AcknowledgeTest.java
@@ -84,40 +84,40 @@ public class AcknowledgeTest extends QpidTestCase
return _queue;
}
- public void testTransactionalSingleAck() throws AMQException
+ public void testTransactionalSingleAck() throws Exception
{
getChannel().setLocalTransactional();
runMessageAck(1, 1, 1, false, 0);
}
- public void testTransactionalMultiAck() throws AMQException
+ public void testTransactionalMultiAck() throws Exception
{
getChannel().setLocalTransactional();
runMessageAck(10, 1, 5, true, 5);
}
- public void testTransactionalAckAll() throws AMQException
+ public void testTransactionalAckAll() throws Exception
{
getChannel().setLocalTransactional();
runMessageAck(10, 1, 0, true, 0);
}
- public void testNonTransactionalSingleAck() throws AMQException
+ public void testNonTransactionalSingleAck() throws Exception
{
runMessageAck(1, 1, 1, false, 0);
}
- public void testNonTransactionalMultiAck() throws AMQException
+ public void testNonTransactionalMultiAck() throws Exception
{
runMessageAck(10, 1, 5, true, 5);
}
- public void testNonTransactionalAckAll() throws AMQException
+ public void testNonTransactionalAckAll() throws Exception
{
runMessageAck(10, 1, 0, true, 0);
}
- protected void runMessageAck(int sendMessageCount, long firstDeliveryTag, long acknowledgeDeliveryTag, boolean acknowledgeMultiple, int remainingUnackedMessages) throws AMQException
+ protected void runMessageAck(int sendMessageCount, long firstDeliveryTag, long acknowledgeDeliveryTag, boolean acknowledgeMultiple, int remainingUnackedMessages) throws Exception
{
//Check store is empty
checkStoreContents(0);
diff --git a/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/BrokerTestHelper_0_8.java b/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/BrokerTestHelper_0_8.java
index 991a0272d4..845c1d55b4 100644
--- a/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/BrokerTestHelper_0_8.java
+++ b/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/BrokerTestHelper_0_8.java
@@ -26,6 +26,7 @@ import org.apache.qpid.framing.BasicContentHeaderProperties;
import org.apache.qpid.framing.ContentHeaderBody;
import org.apache.qpid.framing.abstraction.MessagePublishInfo;
import org.apache.qpid.server.exchange.Exchange;
+import org.apache.qpid.server.security.QpidSecurityException;
import org.apache.qpid.server.util.BrokerTestHelper;
import org.apache.qpid.server.virtualhost.VirtualHost;
@@ -64,7 +65,8 @@ public class BrokerTestHelper_0_8 extends BrokerTestHelper
return new InternalTestProtocolSession(virtualHost, createBrokerMock());
}
- public static void publishMessages(AMQChannel channel, int numberOfMessages, String queueName, String exchangeName) throws AMQException
+ public static void publishMessages(AMQChannel channel, int numberOfMessages, String queueName, String exchangeName)
+ throws AMQException, QpidSecurityException
{
AMQShortString routingKey = new AMQShortString(queueName);
AMQShortString exchangeNameAsShortString = new AMQShortString(exchangeName);
diff --git a/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/InternalTestProtocolSession.java b/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/InternalTestProtocolSession.java
index 1fad8fb41f..7661d98cb4 100644
--- a/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/InternalTestProtocolSession.java
+++ b/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/InternalTestProtocolSession.java
@@ -99,7 +99,7 @@ public class InternalTestProtocolSession extends AMQProtocolEngine implements Pr
MessageContentSource msgContent,
int channelId,
int replyCode,
- AMQShortString replyText) throws AMQException
+ AMQShortString replyText)
{
//To change body of implemented methods use File | Settings | File Templates.
}
@@ -145,7 +145,7 @@ public class InternalTestProtocolSession extends AMQProtocolEngine implements Pr
public void writeDeliver(final ServerMessage msg,
final InstanceProperties props, int channelId,
long deliveryTag,
- AMQShortString consumerTag) throws AMQException
+ AMQShortString consumerTag)
{
_deliveryCount.incrementAndGet();
@@ -175,7 +175,7 @@ public class InternalTestProtocolSession extends AMQProtocolEngine implements Pr
final InstanceProperties props,
int channelId,
long deliveryTag,
- int queueSize) throws AMQException
+ int queueSize)
{
}
@@ -223,7 +223,7 @@ public class InternalTestProtocolSession extends AMQProtocolEngine implements Pr
// Then the AMQMinaProtocolSession can join on the returning future without a NPE.
}
- public void closeSession(AMQSessionModel session, AMQConstant cause, String message) throws AMQException
+ public void closeSession(AMQSessionModel session, AMQConstant cause, String message)
{
super.closeSession(session, cause, message);
@@ -246,7 +246,7 @@ public class InternalTestProtocolSession extends AMQProtocolEngine implements Pr
@Override
public void deliverToClient(Consumer sub, ServerMessage message,
- InstanceProperties props, long deliveryTag) throws AMQException
+ InstanceProperties props, long deliveryTag)
{
_deliveryCount.incrementAndGet();
diff --git a/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/QueueBrowserUsesNoAckTest.java b/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/QueueBrowserUsesNoAckTest.java
index dc687e1075..e213aa8a20 100644
--- a/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/QueueBrowserUsesNoAckTest.java
+++ b/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/QueueBrowserUsesNoAckTest.java
@@ -85,7 +85,7 @@ public class QueueBrowserUsesNoAckTest extends QpidTestCase
return _queue;
}
- public void testQueueBrowserUsesNoAck() throws AMQException
+ public void testQueueBrowserUsesNoAck() throws Exception
{
int sendMessageCount = 2;
int prefetch = 1;
@@ -136,7 +136,7 @@ public class QueueBrowserUsesNoAckTest extends QpidTestCase
assertEquals("Message header count incorrect in the MetaDataMap", messageCount, ((TestableMemoryMessageStore) _messageStore).getMessageCount());
}
- private AMQShortString browse(AMQChannel channel, AMQQueue queue) throws AMQException
+ private AMQShortString browse(AMQChannel channel, AMQQueue queue) throws Exception
{
FieldTable filters = new FieldTable();
filters.put(AMQPFilterTypes.NO_CONSUME.getValue(), true);
diff --git a/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Connection_1_0.java b/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Connection_1_0.java
index 41e2fef03f..cae61f9d80 100644
--- a/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Connection_1_0.java
+++ b/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Connection_1_0.java
@@ -22,7 +22,6 @@ package org.apache.qpid.server.protocol.v1_0;
import java.text.MessageFormat;
import java.util.Collection;
-import org.apache.qpid.AMQException;
import org.apache.qpid.amqp_1_0.transport.ConnectionEndpoint;
import org.apache.qpid.amqp_1_0.transport.ConnectionEventListener;
import org.apache.qpid.amqp_1_0.transport.SessionEndpoint;
@@ -152,7 +151,7 @@ public class Connection_1_0 implements ConnectionEventListener
private volatile boolean _stopped;
@Override
- public void close(AMQConstant cause, String message) throws AMQException
+ public void close(AMQConstant cause, String message)
{
_conn.close();
}
@@ -170,7 +169,7 @@ public class Connection_1_0 implements ConnectionEventListener
}
@Override
- public void closeSession(AMQSessionModel session, AMQConstant cause, String message) throws AMQException
+ public void closeSession(AMQSessionModel session, AMQConstant cause, String message)
{
// TODO
}
diff --git a/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/ConsumerTarget_1_0.java b/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/ConsumerTarget_1_0.java
index 027c40aabe..f3417710a5 100644
--- a/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/ConsumerTarget_1_0.java
+++ b/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/ConsumerTarget_1_0.java
@@ -20,7 +20,6 @@
*/
package org.apache.qpid.server.protocol.v1_0;
-import org.apache.qpid.AMQException;
import org.apache.qpid.amqp_1_0.codec.ValueHandler;
import org.apache.qpid.amqp_1_0.messaging.SectionEncoder;
import org.apache.qpid.amqp_1_0.messaging.SectionEncoderImpl;
@@ -46,6 +45,7 @@ import org.apache.qpid.server.protocol.MessageConverterRegistry;
import org.apache.qpid.server.consumer.AbstractConsumerTarget;
import org.apache.qpid.server.consumer.Consumer;
import org.apache.qpid.server.txn.ServerTransaction;
+import org.apache.qpid.server.util.ConnectionScopedRuntimeException;
import java.nio.ByteBuffer;
import java.util.List;
@@ -112,7 +112,7 @@ class ConsumerTarget_1_0 extends AbstractConsumerTarget
}
}
- public void send(MessageInstance entry, boolean batch) throws AMQException
+ public void send(MessageInstance entry, boolean batch)
{
// TODO
send(entry);
@@ -123,7 +123,7 @@ class ConsumerTarget_1_0 extends AbstractConsumerTarget
// TODO
}
- public void send(final MessageInstance queueEntry) throws AMQException
+ public void send(final MessageInstance queueEntry)
{
ServerMessage serverMessage = queueEntry.getMessage();
Message_1_0 message;
@@ -187,7 +187,7 @@ class ConsumerTarget_1_0 extends AbstractConsumerTarget
catch (AmqpErrorException e)
{
//TODO
- throw new RuntimeException(e);
+ throw new ConnectionScopedRuntimeException(e);
}
Header header = new Header();
diff --git a/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/ExchangeDestination.java b/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/ExchangeDestination.java
index 3d030890e0..5356a6e6a3 100644
--- a/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/ExchangeDestination.java
+++ b/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/ExchangeDestination.java
@@ -20,8 +20,6 @@
*/
package org.apache.qpid.server.protocol.v1_0;
-import java.util.List;
-import org.apache.qpid.AMQException;
import org.apache.qpid.amqp_1_0.type.Outcome;
import org.apache.qpid.amqp_1_0.type.messaging.Accepted;
import org.apache.qpid.amqp_1_0.type.messaging.Rejected;
@@ -29,8 +27,6 @@ import org.apache.qpid.amqp_1_0.type.messaging.TerminusDurability;
import org.apache.qpid.amqp_1_0.type.messaging.TerminusExpiryPolicy;
import org.apache.qpid.server.exchange.Exchange;
import org.apache.qpid.server.message.InstanceProperties;
-import org.apache.qpid.server.message.MessageReference;
-import org.apache.qpid.server.queue.BaseQueue;
import org.apache.qpid.server.txn.ServerTransaction;
public class ExchangeDestination implements ReceivingDestination, SendingDestination
diff --git a/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_Internal_to_v1_0.java b/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_Internal_to_v1_0.java
index f02908391a..1764eec84d 100644
--- a/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_Internal_to_v1_0.java
+++ b/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_Internal_to_v1_0.java
@@ -31,6 +31,7 @@ import org.apache.qpid.amqp_1_0.type.messaging.Data;
import org.apache.qpid.amqp_1_0.type.messaging.Header;
import org.apache.qpid.amqp_1_0.type.messaging.Properties;
import org.apache.qpid.server.message.internal.InternalMessage;
+import org.apache.qpid.server.util.ConnectionScopedRuntimeException;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -132,7 +133,7 @@ public class MessageConverter_Internal_to_v1_0 extends MessageConverter_to_1_0<I
}
catch (IOException e)
{
- throw new RuntimeException(e);
+ throw new ConnectionScopedRuntimeException(e);
}
}
}
diff --git a/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_to_1_0.java b/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_to_1_0.java
index a8a203b247..40f738b8e7 100644
--- a/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_to_1_0.java
+++ b/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_to_1_0.java
@@ -39,6 +39,7 @@ import org.apache.qpid.server.message.ServerMessage;
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.codec.BBDecoder;
import org.apache.qpid.typedmessage.TypedBytesContentReader;
@@ -140,11 +141,11 @@ public abstract class MessageConverter_to_1_0<M extends ServerMessage> implement
}
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);
}
}
return new AmqpValue(list);
diff --git a/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_v1_0_to_Internal.java b/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_v1_0_to_Internal.java
index f639f98dba..ec6d5a924c 100644
--- a/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_v1_0_to_Internal.java
+++ b/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_v1_0_to_Internal.java
@@ -30,6 +30,7 @@ import org.apache.qpid.amqp_1_0.type.messaging.AmqpValue;
import org.apache.qpid.amqp_1_0.type.messaging.Data;
import org.apache.qpid.server.message.internal.InternalMessage;
import org.apache.qpid.server.plugin.MessageConverter;
+import org.apache.qpid.server.util.ConnectionScopedRuntimeException;
import org.apache.qpid.server.virtualhost.VirtualHost;
import org.apache.qpid.transport.codec.BBDecoder;
import org.apache.qpid.typedmessage.TypedBytesContentReader;
@@ -96,7 +97,7 @@ public class MessageConverter_v1_0_to_Internal implements MessageConverter<Messa
{
if(previousSection != null && (previousSection.getClass() != section.getClass() || section instanceof AmqpValue))
{
- throw new RuntimeException("Message is badly formed and has multiple body section which are not all Data or not all AmqpSequence");
+ throw new ConnectionScopedRuntimeException("Message is badly formed and has multiple body section which are not all Data or not all AmqpSequence");
}
else
{
@@ -149,7 +150,7 @@ public class MessageConverter_v1_0_to_Internal implements MessageConverter<Messa
}
catch (AmqpErrorException e)
{
- throw new RuntimeException(e);
+ throw new ConnectionScopedRuntimeException(e);
}
@@ -257,11 +258,11 @@ public class MessageConverter_v1_0_to_Internal implements MessageConverter<Messa
}
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);
}
}
return list;
diff --git a/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageMetaData_1_0.java b/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageMetaData_1_0.java
index be9d7a2d60..f28e25e080 100755
--- a/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageMetaData_1_0.java
+++ b/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageMetaData_1_0.java
@@ -43,6 +43,7 @@ import org.apache.qpid.amqp_1_0.type.messaging.Properties;
import org.apache.qpid.server.message.AMQMessageHeader;
import org.apache.qpid.server.plugin.MessageMetaDataType;
import org.apache.qpid.server.store.StorableMessageMetaData;
+import org.apache.qpid.server.util.ConnectionScopedRuntimeException;
public class MessageMetaData_1_0 implements StorableMessageMetaData
{
@@ -394,7 +395,7 @@ public class MessageMetaData_1_0 implements StorableMessageMetaData
catch (AmqpErrorException e)
{
//TODO
- throw new RuntimeException(e);
+ throw new ConnectionScopedRuntimeException(e);
}
}
diff --git a/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/ProtocolEngine_1_0_0_SASL.java b/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/ProtocolEngine_1_0_0_SASL.java
index d614f44981..fe214eb899 100644
--- a/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/ProtocolEngine_1_0_0_SASL.java
+++ b/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/ProtocolEngine_1_0_0_SASL.java
@@ -20,6 +20,7 @@
*/
package org.apache.qpid.server.protocol.v1_0;
+import java.io.IOException;
import java.io.PrintWriter;
import java.net.SocketAddress;
import java.nio.ByteBuffer;
@@ -42,21 +43,27 @@ import org.apache.qpid.amqp_1_0.transport.FrameOutputHandler;
import org.apache.qpid.amqp_1_0.type.Binary;
import org.apache.qpid.amqp_1_0.type.FrameBody;
import org.apache.qpid.amqp_1_0.type.Symbol;
+import org.apache.qpid.amqp_1_0.type.transport.*;
+import org.apache.qpid.amqp_1_0.type.transport.Error;
import org.apache.qpid.common.QpidProperties;
import org.apache.qpid.common.ServerPropertyNames;
import org.apache.qpid.protocol.ServerProtocolEngine;
import org.apache.qpid.server.model.Broker;
import org.apache.qpid.server.model.Port;
import org.apache.qpid.server.model.Transport;
-import org.apache.qpid.server.protocol.v1_0.Connection_1_0;
import org.apache.qpid.server.security.SubjectCreator;
import org.apache.qpid.server.security.auth.UsernamePrincipal;
+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;
import org.apache.qpid.transport.network.NetworkConnection;
public class ProtocolEngine_1_0_0_SASL implements ServerProtocolEngine, FrameOutputHandler
{
+ private static final org.apache.log4j.Logger
+ _logger = org.apache.log4j.Logger.getLogger(ProtocolEngine_1_0_0_SASL.class);
+
private final Port _port;
private final Transport _transport;
private long _readBytes;
@@ -250,123 +257,165 @@ public class ProtocolEngine_1_0_0_SASL implements ServerProtocolEngine, FrameOut
public synchronized void received(ByteBuffer msg)
{
- _lastReadTime = System.currentTimeMillis();
- if(RAW_LOGGER.isLoggable(Level.FINE))
+ try
{
- ByteBuffer dup = msg.duplicate();
- byte[] data = new byte[dup.remaining()];
- dup.get(data);
- Binary bin = new Binary(data);
- RAW_LOGGER.fine("RECV[" + getRemoteAddress() + "] : " + bin.toString());
- }
- _readBytes += msg.remaining();
- switch(_state)
- {
- case A:
- if(msg.hasRemaining())
- {
- msg.get();
- }
- else
- {
- break;
- }
- case M:
- if(msg.hasRemaining())
- {
- msg.get();
- }
- else
- {
- _state = State.M;
- break;
- }
-
- case Q:
- if(msg.hasRemaining())
- {
- msg.get();
- }
- else
- {
- _state = State.Q;
- break;
- }
- case P:
- if(msg.hasRemaining())
- {
- msg.get();
- }
- else
- {
- _state = State.P;
- break;
- }
- case PROTOCOL:
- if(msg.hasRemaining())
- {
- msg.get();
- }
- else
- {
- _state = State.PROTOCOL;
- break;
- }
- case MAJOR:
- if(msg.hasRemaining())
- {
- _major = msg.get();
- }
- else
- {
- _state = State.MAJOR;
- break;
- }
- case MINOR:
- if(msg.hasRemaining())
- {
- _minor = msg.get();
- }
- else
- {
- _state = State.MINOR;
- break;
- }
- case REVISION:
- if(msg.hasRemaining())
- {
- _revision = msg.get();
-
- _state = State.FRAME;
- }
- else
- {
- _state = State.REVISION;
- break;
- }
- case FRAME:
- if(msg.hasRemaining())
- {
+ _lastReadTime = System.currentTimeMillis();
+ if(RAW_LOGGER.isLoggable(Level.FINE))
+ {
+ ByteBuffer dup = msg.duplicate();
+ byte[] data = new byte[dup.remaining()];
+ dup.get(data);
+ Binary bin = new Binary(data);
+ RAW_LOGGER.fine("RECV[" + getRemoteAddress() + "] : " + bin.toString());
+ }
+ _readBytes += msg.remaining();
+ switch(_state)
+ {
+ case A:
+ if (msg.hasRemaining())
+ {
+ msg.get();
+ }
+ else
+ {
+ break;
+ }
+ case M:
+ if (msg.hasRemaining())
+ {
+ msg.get();
+ }
+ else
+ {
+ _state = State.M;
+ break;
+ }
+
+ case Q:
+ if (msg.hasRemaining())
+ {
+ msg.get();
+ }
+ else
+ {
+ _state = State.Q;
+ break;
+ }
+ case P:
+ if (msg.hasRemaining())
+ {
+ msg.get();
+ }
+ else
+ {
+ _state = State.P;
+ break;
+ }
+ case PROTOCOL:
+ if (msg.hasRemaining())
+ {
+ msg.get();
+ }
+ else
+ {
+ _state = State.PROTOCOL;
+ break;
+ }
+ case MAJOR:
+ if (msg.hasRemaining())
+ {
+ _major = msg.get();
+ }
+ else
+ {
+ _state = State.MAJOR;
+ break;
+ }
+ case MINOR:
+ if (msg.hasRemaining())
+ {
+ _minor = msg.get();
+ }
+ else
+ {
+ _state = State.MINOR;
+ break;
+ }
+ case REVISION:
+ if (msg.hasRemaining())
+ {
+ _revision = msg.get();
+
+ _state = State.FRAME;
+ }
+ else
+ {
+ _state = State.REVISION;
+ break;
+ }
+ case FRAME:
+ if (msg.hasRemaining())
+ {
_frameHandler = _frameHandler.parse(msg);
- }
- }
-
+ }
+ }
+ }
+ catch(RuntimeException e)
+ {
+ exception(e);
+ }
}
- public void exception(Throwable t)
+ public void exception(Throwable throwable)
{
- t.printStackTrace();
+ if (throwable instanceof IOException)
+ {
+ _logger.info("IOException caught in " + this + ", connection closed implicitly: " + throwable);
+ }
+ else
+ {
+
+ try
+ {
+ final Error err = new Error();
+ err.setCondition(AmqpError.INTERNAL_ERROR);
+ err.setDescription(throwable.getMessage());
+ _conn.close(err);
+ close();
+ }
+ catch(TransportException e)
+ {
+ _logger.info("Error when handling exception",e);
+ }
+ finally
+ {
+ if(throwable instanceof java.lang.Error)
+ {
+ throw (java.lang.Error) throwable;
+ }
+ if(throwable instanceof ServerScopedRuntimeException)
+ {
+ throw (ServerScopedRuntimeException) throwable;
+ }
+ }
+ }
}
public void closed()
{
- // todo
- _conn.inputClosed();
- if (_conn != null && _conn.getConnectionEventListener() != null)
+ try
{
- ((Connection_1_0) _conn.getConnectionEventListener()).closed();
+ // todo
+ _conn.inputClosed();
+ if (_conn != null && _conn.getConnectionEventListener() != null)
+ {
+ ((Connection_1_0) _conn.getConnectionEventListener()).closed();
+ }
+ }
+ catch(RuntimeException e)
+ {
+ exception(e);
}
-
}
public long getCreateTime()
diff --git a/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/QueueDestination.java b/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/QueueDestination.java
index 3d6bb5e3db..4fefbe9f7d 100644
--- a/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/QueueDestination.java
+++ b/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/QueueDestination.java
@@ -49,37 +49,22 @@ public class QueueDestination extends MessageSourceDestination implements Sendin
public Outcome send(final Message_1_0 message, ServerTransaction txn)
{
- try
+ txn.enqueue(getQueue(),message, new ServerTransaction.Action()
{
- txn.enqueue(getQueue(),message, new ServerTransaction.Action()
+
+
+ public void postCommit()
{
+ getQueue().enqueue(message,null);
+ }
+
+ public void onRollback()
+ {
+ // NO-OP
+ }
+ });
- public void postCommit()
- {
- try
- {
- getQueue().enqueue(message,null);
- }
- catch (Exception e)
- {
- // TODO
- throw new RuntimeException(e);
- }
-
- }
-
- public void onRollback()
- {
- // NO-OP
- }
- });
- }
- catch(Exception e)
- {
- _logger.error("Send error", e);
- throw new RuntimeException(e);
- }
return ACCEPTED;
}
diff --git a/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java b/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java
index f796a4b2e3..546cc79f9e 100644
--- a/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java
+++ b/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java
@@ -30,9 +30,7 @@ import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
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.security.QpidSecurityException;
import org.apache.qpid.amqp_1_0.transport.DeliveryStateHandler;
import org.apache.qpid.amqp_1_0.transport.LinkEndpoint;
import org.apache.qpid.amqp_1_0.transport.SendingLinkEndpoint;
@@ -64,7 +62,9 @@ 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.server.virtualhost.VirtualHost;
+import org.apache.qpid.server.virtualhost.QueueExistsException;
public class SendingLink_1_0 implements SendingLinkListener, Link_1_0, DeliveryStateHandler
{
@@ -324,7 +324,7 @@ public class SendingLink_1_0 implements SendingLinkListener, Link_1_0, DeliveryS
{
_vhost.removeQueue(tempQueue);
}
- catch (AMQException e)
+ catch (QpidSecurityException e)
{
//TODO
_logger.error("Error removing queue", e);
@@ -348,20 +348,15 @@ public class SendingLink_1_0 implements SendingLinkListener, Link_1_0, DeliveryS
qd = new QueueDestination(queue);
}
- catch (AMQSecurityException e)
+ catch (QpidSecurityException e)
{
_logger.error("Security error", e);
- throw new RuntimeException(e);
+ throw new ConnectionScopedRuntimeException(e);
}
- catch (AMQInternalException e)
+ catch (QueueExistsException e)
{
- _logger.error("Internal error", e);
- throw new RuntimeException(e);
- }
- catch (AMQException e)
- {
- _logger.error("Error", e);
- throw new RuntimeException(e);
+ _logger.error("A randomly generated temporary queue name collided with an existing queue",e);
+ throw new ConnectionScopedRuntimeException(e);
}
@@ -372,7 +367,7 @@ public class SendingLink_1_0 implements SendingLinkListener, Link_1_0, DeliveryS
}
else
{
- throw new RuntimeException("Unknown destination type");
+ throw new ConnectionScopedRuntimeException("Unknown destination type");
}
if(_target != null)
@@ -398,10 +393,21 @@ public class SendingLink_1_0 implements SendingLinkListener, Link_1_0, DeliveryS
messageFilter == null ? null : new SimpleFilterManager(messageFilter),
Message_1_0.class, name, options);
}
- catch (AMQException e)
+ catch (QpidSecurityException e)
{
//TODO
- _logger.error("Error registering subscription", e);
+ _logger.info("Error registering subscription", e);
+ throw new ConnectionScopedRuntimeException(e);
+ }
+ catch (MessageSource.ExistingExclusiveConsumer e)
+ {
+ _logger.info("Cannot add a consumer to the destination as there is already an exclusive consumer");
+ throw new ConnectionScopedRuntimeException(e);
+ }
+ catch (MessageSource.ExistingConsumerPreventsExclusive e)
+ {
+ _logger.info("Cannot add an exclusive consumer to the destination as there is already a consumer");
+ throw new ConnectionScopedRuntimeException(e);
}
}
@@ -419,18 +425,7 @@ public class SendingLink_1_0 implements SendingLinkListener, Link_1_0, DeliveryS
// if not durable or close
if(!TerminusDurability.UNSETTLED_STATE.equals(_durability))
{
-
- try
- {
-
- _consumer.close();
-
- }
- catch (AMQException e)
- {
- //TODO
- _logger.error("Error unregistering subscription", e);
- }
+ _consumer.close();
Modified state = new Modified();
state.setDeliveryFailed(true);
@@ -452,10 +447,10 @@ public class SendingLink_1_0 implements SendingLinkListener, Link_1_0, DeliveryS
{
_vhost.removeQueue((AMQQueue)_queue);
}
- catch(AMQException e)
+ catch (QpidSecurityException e)
{
//TODO
- _logger.error("Error removing queue", e);
+ _logger.error("Error registering subscription", e);
}
}
diff --git a/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java b/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java
index beed6be84b..c055d1e840 100644
--- a/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java
+++ b/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java
@@ -36,8 +36,7 @@ import org.apache.qpid.amqp_1_0.type.transaction.TxnCapability;
import org.apache.qpid.amqp_1_0.type.transport.*;
import org.apache.qpid.amqp_1_0.type.transport.Error;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.AMQSecurityException;
+import org.apache.qpid.server.security.QpidSecurityException;
import org.apache.qpid.protocol.AMQConstant;
import org.apache.qpid.server.exchange.Exchange;
import org.apache.qpid.server.logging.LogSubject;
@@ -51,7 +50,9 @@ import org.apache.qpid.server.queue.AMQQueue;
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.server.virtualhost.VirtualHost;
+import org.apache.qpid.server.virtualhost.QueueExistsException;
import java.util.*;
@@ -357,7 +358,7 @@ public class Session_1_0 implements SessionEventListener, AMQSessionModel, LogSu
{
_vhost.removeQueue(tempQueue);
}
- catch (AMQException e)
+ catch (QpidSecurityException e)
{
//TODO
_logger.error("Error removing queue from vhost", e);
@@ -391,15 +392,16 @@ public class Session_1_0 implements SessionEventListener, AMQSessionModel, LogSu
}
}
- catch (AMQSecurityException e)
+ catch (QpidSecurityException e)
{
//TODO
- _logger.error("Security error", e);
+ _logger.info("Security error", e);
+ throw new ConnectionScopedRuntimeException(e);
}
- catch (AMQException e)
+ catch (QueueExistsException e)
{
- //TODO
- _logger.error("Error", e);
+ _logger.error("A temporary queue was created with a name which collided with an existing queue name");
+ throw new ConnectionScopedRuntimeException(e);
}
return queue;
@@ -485,14 +487,14 @@ public class Session_1_0 implements SessionEventListener, AMQSessionModel, LogSu
}
@Override
- public void close() throws AMQException
+ public void close()
{
// TODO - required for AMQSessionModel / management initiated closing
}
@Override
- public void close(AMQConstant cause, String message) throws AMQException
+ public void close(AMQConstant cause, String message)
{
// TODO - required for AMQSessionModel
}
@@ -504,7 +506,7 @@ public class Session_1_0 implements SessionEventListener, AMQSessionModel, LogSu
}
@Override
- public void checkTransactionStatus(long openWarn, long openClose, long idleWarn, long idleClose) throws AMQException
+ public void checkTransactionStatus(long openWarn, long openClose, long idleWarn, long idleClose)
{
// TODO - required for AMQSessionModel / long running transaction detection
}
diff --git a/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java b/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java
index bc8d157346..5d56329c20 100644
--- a/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java
+++ b/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java
@@ -40,6 +40,7 @@ import org.apache.qpid.server.store.Event;
import org.apache.qpid.server.store.EventListener;
import org.apache.qpid.server.store.MessageStore;
import org.apache.qpid.server.store.MessageStoreConstants;
+import org.apache.qpid.server.store.StoreException;
import org.apache.qpid.util.FileUtils;
/**
@@ -99,7 +100,7 @@ public class DerbyMessageStore extends AbstractJDBCMessageStore implements Messa
return "bigint";
}
- protected void doClose() throws SQLException
+ protected void doClose()
{
try
{
@@ -117,7 +118,7 @@ public class DerbyMessageStore extends AbstractJDBCMessageStore implements Messa
else
{
getLogger().error("Exception whilst shutting down the store: " + e);
- throw e;
+ throw new StoreException("Error closing message store", e);
}
}
}
@@ -307,7 +308,7 @@ public class DerbyMessageStore extends AbstractJDBCMessageStore implements Messa
catch (SQLException e)
{
closeConnection(conn);
- throw new RuntimeException("Exception while processing store size change", e);
+ throw new StoreException("Exception while processing store size change", e);
}
}
}
@@ -359,7 +360,7 @@ public class DerbyMessageStore extends AbstractJDBCMessageStore implements Messa
catch (SQLException e)
{
closeConnection(conn);
- throw new RuntimeException("Error reducing on disk size", e);
+ throw new StoreException("Error reducing on disk size", e);
}
finally
{
@@ -407,7 +408,7 @@ public class DerbyMessageStore extends AbstractJDBCMessageStore implements Messa
catch (SQLException e)
{
closeConnection(conn);
- throw new RuntimeException("Error establishing on disk size", e);
+ throw new StoreException("Error establishing on disk size", e);
}
finally
{
diff --git a/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStore.java b/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStore.java
index 6fdfa40561..621759ef85 100644
--- a/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStore.java
+++ b/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStore.java
@@ -30,11 +30,11 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import org.apache.log4j.Logger;
-import org.apache.qpid.AMQStoreException;
import org.apache.qpid.server.model.VirtualHost;
import org.apache.qpid.server.plugin.JDBCConnectionProviderFactory;
import org.apache.qpid.server.store.AbstractJDBCMessageStore;
import org.apache.qpid.server.store.MessageStore;
+import org.apache.qpid.server.store.StoreException;
import org.apache.qpid.server.store.StoreFuture;
import org.apache.qpid.server.store.Transaction;
@@ -252,7 +252,7 @@ public class JDBCMessageStore extends AbstractJDBCMessageStore implements Messag
}
@Override
- protected void doClose() throws AMQStoreException
+ protected void doClose()
{
while(!_transactions.isEmpty())
{
@@ -265,7 +265,7 @@ public class JDBCMessageStore extends AbstractJDBCMessageStore implements Messag
}
catch (SQLException e)
{
- throw new AMQStoreException("Unable to close connection provider ", e);
+ throw new StoreException("Unable to close connection provider ", e);
}
}
@@ -430,7 +430,7 @@ public class JDBCMessageStore extends AbstractJDBCMessageStore implements Messag
}
@Override
- public void commitTran() throws AMQStoreException
+ public void commitTran()
{
try
{
@@ -443,7 +443,7 @@ public class JDBCMessageStore extends AbstractJDBCMessageStore implements Messag
}
@Override
- public StoreFuture commitTranAsync() throws AMQStoreException
+ public StoreFuture commitTranAsync()
{
try
{
@@ -456,7 +456,7 @@ public class JDBCMessageStore extends AbstractJDBCMessageStore implements Messag
}
@Override
- public void abortTran() throws AMQStoreException
+ public void abortTran()
{
try
{
diff --git a/java/broker-plugins/management-amqp/src/main/java/org/apache/qpid/server/management/amqp/ManagementNode.java b/java/broker-plugins/management-amqp/src/main/java/org/apache/qpid/server/management/amqp/ManagementNode.java
index 2b94aae5b7..7d76a0ee8e 100644
--- a/java/broker-plugins/management-amqp/src/main/java/org/apache/qpid/server/management/amqp/ManagementNode.java
+++ b/java/broker-plugins/management-amqp/src/main/java/org/apache/qpid/server/management/amqp/ManagementNode.java
@@ -20,8 +20,7 @@
*/
package org.apache.qpid.server.management.amqp;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.AMQSecurityException;
+import org.apache.qpid.server.security.QpidSecurityException;
import org.apache.qpid.server.consumer.Consumer;
import org.apache.qpid.server.consumer.ConsumerTarget;
import org.apache.qpid.server.filter.FilterManager;
@@ -373,7 +372,7 @@ class ManagementNode implements MessageSource<ManagementNodeConsumer,ManagementN
}
catch(RuntimeException e)
{
- if (e instanceof AccessControlException || e.getCause() instanceof AMQSecurityException)
+ if (e instanceof AccessControlException || e.getCause() instanceof QpidSecurityException)
{
response = createFailureResponse(message, STATUS_CODE_FORBIDDEN, e.getMessage());
}
@@ -478,7 +477,7 @@ class ManagementNode implements MessageSource<ManagementNodeConsumer,ManagementN
}
catch(RuntimeException e)
{
- if (e instanceof AccessControlException || e.getCause() instanceof AMQSecurityException)
+ if (e instanceof AccessControlException || e.getCause() instanceof QpidSecurityException)
{
responseHeader.setHeader(STATUS_CODE_HEADER, STATUS_CODE_FORBIDDEN);
}
@@ -516,7 +515,7 @@ class ManagementNode implements MessageSource<ManagementNodeConsumer,ManagementN
}
catch(RuntimeException e)
{
- if (e instanceof AccessControlException || e.getCause() instanceof AMQSecurityException)
+ if (e instanceof AccessControlException || e.getCause() instanceof QpidSecurityException)
{
return createFailureResponse(requestMessage, STATUS_CODE_FORBIDDEN, e.getMessage());
}
@@ -940,7 +939,7 @@ class ManagementNode implements MessageSource<ManagementNodeConsumer,ManagementN
final FilterManager filters,
final Class<? extends ServerMessage> messageClass,
final String consumerName,
- final EnumSet<Consumer.Option> options) throws AMQException
+ final EnumSet<Consumer.Option> options)
{
final ManagementNodeConsumer managementNodeConsumer = new ManagementNodeConsumer(consumerName,this, target);
@@ -1111,7 +1110,7 @@ class ManagementNode implements MessageSource<ManagementNodeConsumer,ManagementN
}
@Override
- public boolean expired() throws AMQException
+ public boolean expired()
{
return false;
}
@@ -1167,7 +1166,7 @@ class ManagementNode implements MessageSource<ManagementNodeConsumer,ManagementN
}
@Override
- public boolean resend() throws AMQException
+ public boolean resend()
{
return false;
}
diff --git a/java/broker-plugins/management-amqp/src/main/java/org/apache/qpid/server/management/amqp/ManagementNodeConsumer.java b/java/broker-plugins/management-amqp/src/main/java/org/apache/qpid/server/management/amqp/ManagementNodeConsumer.java
index 98bb20d364..008f16883a 100644
--- a/java/broker-plugins/management-amqp/src/main/java/org/apache/qpid/server/management/amqp/ManagementNodeConsumer.java
+++ b/java/broker-plugins/management-amqp/src/main/java/org/apache/qpid/server/management/amqp/ManagementNodeConsumer.java
@@ -20,7 +20,6 @@
*/
package org.apache.qpid.server.management.amqp;
-import org.apache.qpid.AMQException;
import org.apache.qpid.server.consumer.Consumer;
import org.apache.qpid.server.consumer.ConsumerTarget;
import org.apache.qpid.server.message.internal.InternalMessage;
@@ -124,7 +123,7 @@ class ManagementNodeConsumer implements Consumer
}
@Override
- public void close() throws AMQException
+ public void close()
{
}
@@ -161,7 +160,7 @@ class ManagementNodeConsumer implements Consumer
}
@Override
- public void flush() throws AMQException
+ public void flush()
{
}
@@ -186,10 +185,6 @@ class ManagementNodeConsumer implements Consumer
_queue.add(responseEntry);
}
}
- catch (AMQException e)
- {
- e.printStackTrace();
- }
finally
{
releaseSendLock();
@@ -230,10 +225,6 @@ class ManagementNodeConsumer implements Consumer
}
}
}
- catch (AMQException e)
- {
- throw new RuntimeException(e);
- }
finally
{
releaseSendLock();
diff --git a/java/broker-plugins/management-amqp/src/main/java/org/apache/qpid/server/management/amqp/ManagementResponse.java b/java/broker-plugins/management-amqp/src/main/java/org/apache/qpid/server/management/amqp/ManagementResponse.java
index e25f327420..59ab849848 100644
--- a/java/broker-plugins/management-amqp/src/main/java/org/apache/qpid/server/management/amqp/ManagementResponse.java
+++ b/java/broker-plugins/management-amqp/src/main/java/org/apache/qpid/server/management/amqp/ManagementResponse.java
@@ -20,7 +20,6 @@
*/
package org.apache.qpid.server.management.amqp;
-import org.apache.qpid.AMQException;
import org.apache.qpid.server.consumer.Consumer;
import org.apache.qpid.server.filter.Filterable;
import org.apache.qpid.server.message.InstanceProperties;
@@ -127,7 +126,7 @@ class ManagementResponse implements MessageInstance<ManagementResponse,Managemen
}
@Override
- public boolean expired() throws AMQException
+ public boolean expired()
{
return false;
}
@@ -183,7 +182,7 @@ class ManagementResponse implements MessageInstance<ManagementResponse,Managemen
}
@Override
- public boolean resend() throws AMQException
+ public boolean resend()
{
return false;
}
diff --git a/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java b/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
index 3375a784ea..08b99a206d 100644
--- a/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
+++ b/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
@@ -76,6 +76,7 @@ import org.apache.qpid.server.model.VirtualHost;
import org.apache.qpid.server.model.adapter.AbstractPluginAdapter;
import org.apache.qpid.server.plugin.PluginFactory;
import org.apache.qpid.server.util.MapValueConverter;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
import org.apache.qpid.transport.network.security.ssl.QpidMultipleTrustManager;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Server;
@@ -181,7 +182,7 @@ public class HttpManagement extends AbstractPluginAdapter implements HttpManagem
}
catch (Exception e)
{
- throw new RuntimeException("Failed to start HTTP management on ports : " + httpPorts, e);
+ throw new ServerScopedRuntimeException("Failed to start HTTP management on ports : " + httpPorts, e);
}
CurrentActor.get().message(ManagementConsoleMessages.READY(OPERATIONAL_LOGGING_NAME));
@@ -198,7 +199,7 @@ public class HttpManagement extends AbstractPluginAdapter implements HttpManagem
}
catch (Exception e)
{
- throw new RuntimeException("Failed to stop HTTP management on ports : " + getHttpPorts(getBroker().getPorts()), e);
+ throw new ServerScopedRuntimeException("Failed to stop HTTP management on ports : " + getHttpPorts(getBroker().getPorts()), e);
}
}
@@ -310,7 +311,7 @@ public class HttpManagement extends AbstractPluginAdapter implements HttpManagem
}
catch (GeneralSecurityException e)
{
- throw new RuntimeException("Cannot configure port " + port.getName() + " for transport " + Transport.SSL, e);
+ throw new ServerScopedRuntimeException("Cannot configure port " + port.getName() + " for transport " + Transport.SSL, e);
}
connector = new SslSocketConnector(factory);
diff --git a/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementUtil.java b/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementUtil.java
index f6674b5152..9a2f0dd1f6 100644
--- a/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementUtil.java
+++ b/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementUtil.java
@@ -50,6 +50,7 @@ import org.apache.qpid.server.security.auth.SubjectAuthenticationResult;
import org.apache.qpid.server.security.auth.UsernamePrincipal;
import org.apache.qpid.server.security.auth.manager.ExternalAuthenticationManager;
import org.apache.qpid.server.security.auth.manager.ExternalAuthenticationManagerFactory;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
import org.apache.qpid.transport.network.security.ssl.SSLUtil;
public class HttpManagementUtil
@@ -138,7 +139,7 @@ public class HttpManagementUtil
}
catch (PrivilegedActionException e)
{
- throw new RuntimeException("Unable to perform access check", e);
+ throw new ServerScopedRuntimeException("Unable to perform access check", e);
}
}
finally
diff --git a/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/AbstractServlet.java b/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/AbstractServlet.java
index ee481ebdbe..0381b711bc 100644
--- a/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/AbstractServlet.java
+++ b/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/AbstractServlet.java
@@ -40,6 +40,7 @@ import org.apache.qpid.server.management.plugin.HttpManagementConfiguration;
import org.apache.qpid.server.management.plugin.HttpManagementUtil;
import org.apache.qpid.server.model.Broker;
import org.apache.qpid.server.security.SecurityManager;
+import org.apache.qpid.server.util.ConnectionScopedRuntimeException;
import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
@@ -214,7 +215,16 @@ public abstract class AbstractServlet extends HttpServlet
catch (PrivilegedActionException e)
{
LOGGER.error("Unable to perform action", e);
- throw new RuntimeException(e.getCause());
+ Throwable cause = e.getCause();
+ if(cause instanceof RuntimeException)
+ {
+ throw (RuntimeException)cause;
+ }
+ if(cause instanceof Error)
+ {
+ throw (Error)cause;
+ }
+ throw new ConnectionScopedRuntimeException(e.getCause());
}
finally
{
@@ -255,7 +265,7 @@ public abstract class AbstractServlet extends HttpServlet
}
catch (IOException e)
{
- throw new RuntimeException("Failed to send error response code " + errorCode, e);
+ throw new ConnectionScopedRuntimeException("Failed to send error response code " + errorCode, e);
}
}
diff --git a/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java b/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
index ca11bd9465..45e0c2dab8 100644
--- a/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
+++ b/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
@@ -27,7 +27,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
-import org.apache.qpid.AMQSecurityException;
+import org.apache.qpid.server.security.QpidSecurityException;
import org.apache.qpid.server.model.*;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.SerializationConfig;
@@ -498,7 +498,7 @@ public class RestServlet extends AbstractServlet
private void setResponseStatus(HttpServletResponse response, RuntimeException e) throws IOException
{
- if (e instanceof AccessControlException || e.getCause() instanceof AMQSecurityException)
+ if (e instanceof AccessControlException || e.getCause() instanceof QpidSecurityException)
{
if (LOGGER.isDebugEnabled())
{
diff --git a/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/SaslServlet.java b/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/SaslServlet.java
index 9ad52007ab..a29a875071 100644
--- a/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/SaslServlet.java
+++ b/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/SaslServlet.java
@@ -21,6 +21,7 @@
package org.apache.qpid.server.management.plugin.servlet.rest;
import org.apache.commons.codec.binary.Base64;
+import org.apache.qpid.server.util.ConnectionScopedRuntimeException;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.SerializationConfig;
@@ -210,7 +211,7 @@ public class SaslServlet extends AbstractServlet
}
if (!saslAuthEnabled)
{
- throw new RuntimeException("Sasl authentication disabled.");
+ throw new ConnectionScopedRuntimeException("Sasl authentication disabled.");
}
}
diff --git a/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagedObjectRegistry.java b/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagedObjectRegistry.java
index 32aac51008..e2b9a98784 100644
--- a/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagedObjectRegistry.java
+++ b/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagedObjectRegistry.java
@@ -31,6 +31,7 @@ import org.apache.qpid.server.model.Port;
import org.apache.qpid.server.model.Transport;
import org.apache.qpid.server.security.auth.jmx.JMXPasswordAuthenticator;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
import org.apache.qpid.ssl.SSLContextFactory;
import javax.management.JMException;
@@ -134,7 +135,7 @@ public class JMXManagedObjectRegistry implements ManagedObjectRegistry
}
catch (GeneralSecurityException e)
{
- throw new RuntimeException("Unable to create SSLContext for key store", e);
+ throw new ServerScopedRuntimeException("Unable to create SSLContext for key store", e);
}
CurrentActor.get().message(ManagementConsoleMessages.SSL_KEYSTORE(keyStore.getName()));
diff --git a/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagement.java b/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagement.java
index 18e9f9f809..e418275d7e 100644
--- a/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagement.java
+++ b/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagement.java
@@ -54,6 +54,7 @@ import org.apache.qpid.server.model.adapter.AbstractPluginAdapter;
import org.apache.qpid.server.plugin.PluginFactory;
import org.apache.qpid.server.plugin.QpidServiceLoader;
import org.apache.qpid.server.util.MapValueConverter;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
public class JMXManagement extends AbstractPluginAdapter implements ConfigurationChangeListener
{
@@ -110,7 +111,7 @@ public class JMXManagement extends AbstractPluginAdapter implements Configuratio
}
catch (Exception e)
{
- throw new RuntimeException("Couldn't start JMX management", e);
+ throw new ServerScopedRuntimeException("Couldn't start JMX management", e);
}
return true;
}
diff --git a/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ConnectionMBean.java b/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ConnectionMBean.java
index d0c0d5e73f..34366a196c 100644
--- a/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ConnectionMBean.java
+++ b/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ConnectionMBean.java
@@ -40,6 +40,7 @@ import org.apache.qpid.server.jmx.ManagedObject;
import org.apache.qpid.server.model.Connection;
import org.apache.qpid.server.model.Session;
import org.apache.qpid.server.model.Statistics;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
public class ConnectionMBean extends AbstractStatisticsGatheringMBean<Connection> implements ManagedConnection
{
@@ -60,7 +61,7 @@ public class ConnectionMBean extends AbstractStatisticsGatheringMBean<Connection
catch (JMException ex)
{
// This is not expected to ever occur.
- throw new RuntimeException("Got JMException in static initializer.", ex);
+ throw new ServerScopedRuntimeException("Got JMException in static initializer.", ex);
}
}
diff --git a/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ExchangeMBean.java b/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ExchangeMBean.java
index 3e1a47c431..407da0fd3f 100644
--- a/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ExchangeMBean.java
+++ b/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ExchangeMBean.java
@@ -29,6 +29,7 @@ import org.apache.qpid.server.model.Exchange;
import org.apache.qpid.server.model.LifetimePolicy;
import org.apache.qpid.server.model.Queue;
import org.apache.qpid.server.model.VirtualHost;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
import javax.management.JMException;
import javax.management.MalformedObjectNameException;
@@ -106,7 +107,7 @@ public class ExchangeMBean extends AMQManagedObject implements ManagedExchange
}
catch(OpenDataException e)
{
- throw new RuntimeException("Unexpected Error creating ArrayType", e);
+ throw new ServerScopedRuntimeException("Unexpected Error creating ArrayType", e);
}
}
diff --git a/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/LoggingManagementMBean.java b/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/LoggingManagementMBean.java
index d6f4b5d8c9..848a846911 100644
--- a/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/LoggingManagementMBean.java
+++ b/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/LoggingManagementMBean.java
@@ -28,6 +28,7 @@ import org.apache.qpid.server.jmx.ManagedObject;
import org.apache.qpid.server.jmx.ManagedObjectRegistry;
import org.apache.qpid.server.logging.log4j.LoggingManagementFacade;
import org.apache.qpid.server.logging.log4j.LoggingFacadeException;
+import org.apache.qpid.server.util.ConnectionScopedRuntimeException;
import javax.management.JMException;
import javax.management.openmbean.CompositeData;
@@ -314,7 +315,7 @@ public class LoggingManagementMBean extends AMQManagedObject implements LoggingM
catch (OpenDataException ode)
{
// Should not happen
- throw new RuntimeException(ode);
+ throw new ConnectionScopedRuntimeException(ode);
}
}
diff --git a/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/QueueMBean.java b/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/QueueMBean.java
index d74aa41244..1365ceb06a 100644
--- a/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/QueueMBean.java
+++ b/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/QueueMBean.java
@@ -57,6 +57,7 @@ import org.apache.qpid.server.model.VirtualHost;
import org.apache.qpid.server.queue.NotificationCheck;
import org.apache.qpid.server.queue.QueueEntry;
import org.apache.qpid.server.queue.QueueEntryVisitor;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
public class QueueMBean extends AMQManagedObject implements ManagedQueue, QueueNotificationListener
{
@@ -109,7 +110,7 @@ public class QueueMBean extends AMQManagedObject implements ManagedQueue, QueueN
}
catch (OpenDataException e)
{
- throw new RuntimeException(e);
+ throw new ServerScopedRuntimeException(e);
}
}
diff --git a/java/broker-plugins/websocket/src/main/java/org/apache/qpid/server/transport/websocket/WebSocketProvider.java b/java/broker-plugins/websocket/src/main/java/org/apache/qpid/server/transport/websocket/WebSocketProvider.java
index fde93a27e3..81dcb05a41 100644
--- a/java/broker-plugins/websocket/src/main/java/org/apache/qpid/server/transport/websocket/WebSocketProvider.java
+++ b/java/broker-plugins/websocket/src/main/java/org/apache/qpid/server/transport/websocket/WebSocketProvider.java
@@ -28,6 +28,7 @@ import org.apache.qpid.server.model.Transport;
import org.apache.qpid.server.protocol.AmqpProtocolVersion;
import org.apache.qpid.server.protocol.MultiVersionProtocolEngineFactory;
import org.apache.qpid.server.transport.AcceptingTransport;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
import org.apache.qpid.transport.Binary;
import org.apache.qpid.transport.Sender;
import org.apache.qpid.transport.network.NetworkConnection;
@@ -144,9 +145,13 @@ class WebSocketProvider implements AcceptingTransport
{
_server.start();
}
+ catch(RuntimeException e)
+ {
+ throw e;
+ }
catch (Exception e)
{
- throw new RuntimeException(e);
+ throw new ServerScopedRuntimeException(e);
}
}
diff --git a/java/common/src/main/java/org/apache/qpid/AMQStoreException.java b/java/common/src/main/java/org/apache/qpid/AMQStoreException.java
deleted file mode 100644
index 45aa36a20b..0000000000
--- a/java/common/src/main/java/org/apache/qpid/AMQStoreException.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid;
-
-/**
- * StoreException is a specific type of internal error relating to errors in the message store, such as {@link java.sql.SQLException}.
- */
-public class AMQStoreException extends AMQInternalException
-{
- /** serialVersionUID */
- private static final long serialVersionUID = 2859681947490637496L;
-
- /**
- * Creates an exception with an optional message and optional underlying cause.
- *
- * @param msg The exception message. May be null if not to be set.
- * @param cause The underlying cause of the exception. May be null if not to be set.
- */
- public AMQStoreException(String msg, Throwable cause)
- {
- super(((msg == null) ? "Store error" : msg), cause);
- }
-
- public AMQStoreException(String msg)
- {
- this(msg, null);
- }
-}
diff --git a/java/systests/src/main/java/org/apache/qpid/server/store/MessageStoreTest.java b/java/systests/src/main/java/org/apache/qpid/server/store/MessageStoreTest.java
index de36c6e413..bdcdbe23c2 100644
--- a/java/systests/src/main/java/org/apache/qpid/server/store/MessageStoreTest.java
+++ b/java/systests/src/main/java/org/apache/qpid/server/store/MessageStoreTest.java
@@ -51,6 +51,7 @@ import org.apache.qpid.server.queue.PriorityQueue;
import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.queue.ConflationQueue;
import org.apache.qpid.server.queue.StandardQueue;
+import org.apache.qpid.server.security.QpidSecurityException;
import org.apache.qpid.server.txn.AutoCommitTransaction;
import org.apache.qpid.server.txn.ServerTransaction;
import org.apache.qpid.server.util.BrokerTestHelper;
@@ -630,7 +631,7 @@ public class MessageStoreTest extends QpidTestCase
}
- private void createAllQueues()
+ private void createAllQueues() throws Exception
{
//Register Durable Priority Queue
createQueue(durablePriorityQueueName, true, true, false, false);
@@ -651,7 +652,7 @@ public class MessageStoreTest extends QpidTestCase
createQueue(queueName, false, false, false, false);
}
- private void createAllTopicQueues()
+ private void createAllTopicQueues() throws Exception
{
//Register Durable Priority Queue
createQueue(durablePriorityTopicQueueName, true, true, false, false);
@@ -667,6 +668,7 @@ public class MessageStoreTest extends QpidTestCase
}
private void createQueue(String queueName, boolean usePriority, boolean durable, boolean exclusive, boolean lastValueQueue)
+ throws Exception
{
Map<String,Object> queueArguments = null;
@@ -689,22 +691,16 @@ public class MessageStoreTest extends QpidTestCase
AMQQueue queue = null;
//Ideally we would be able to use the QueueDeclareHandler here.
- try
- {
- queue = getVirtualHost().createQueue(UUIDGenerator.generateRandomUUID(), queueName, durable, queueOwner, false, exclusive,
- false, queueArguments);
+ queue = getVirtualHost().createQueue(UUIDGenerator.generateRandomUUID(), queueName, durable, queueOwner, false, exclusive,
+ false, queueArguments);
+
+ validateQueueProperties(queue, usePriority, durable, exclusive, lastValueQueue);
- validateQueueProperties(queue, usePriority, durable, exclusive, lastValueQueue);
- }
- catch (AMQException e)
- {
- fail(e.getMessage());
- }
}
- private Map<String, Exchange> createExchanges()
+ private Map<String, Exchange> createExchanges() throws Exception
{
Map<String, Exchange> exchanges = new HashMap<String, Exchange>();
@@ -718,18 +714,11 @@ public class MessageStoreTest extends QpidTestCase
return exchanges;
}
- private Exchange createExchange(ExchangeType<?> type, String name, boolean durable)
+ private Exchange createExchange(ExchangeType<?> type, String name, boolean durable) throws Exception
{
Exchange exchange = null;
- try
- {
- exchange = getVirtualHost().createExchange(null, name, type.getType(), durable, false, null);
- }
- catch (AMQException e)
- {
- fail(e.getMessage());
- }
+ exchange = getVirtualHost().createExchange(null, name, type.getType(), durable, false, null);
return exchange;
}
diff --git a/java/systests/src/main/java/org/apache/qpid/server/store/QuotaMessageStore.java b/java/systests/src/main/java/org/apache/qpid/server/store/QuotaMessageStore.java
index 75ce0e68d8..19e258d060 100644
--- a/java/systests/src/main/java/org/apache/qpid/server/store/QuotaMessageStore.java
+++ b/java/systests/src/main/java/org/apache/qpid/server/store/QuotaMessageStore.java
@@ -23,7 +23,6 @@ package org.apache.qpid.server.store;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
-import org.apache.qpid.AMQStoreException;
import org.apache.qpid.server.message.EnqueueableMessage;
import org.apache.qpid.server.message.MessageContentSource;
import org.apache.qpid.server.model.VirtualHost;
@@ -49,7 +48,6 @@ public class
@Override
public void configureConfigStore(VirtualHost virtualHost, ConfigurationRecoveryHandler recoveryHandler)
- throws Exception
{
Object overfullAttr = virtualHost.getAttribute(MessageStoreConstants.OVERFULL_SIZE_ATTRIBUTE);
_persistentSizeHighThreshold = overfullAttr == null
@@ -76,13 +74,13 @@ public class
@Override
public void configureMessageStore(VirtualHost virtualHost, MessageStoreRecoveryHandler recoveryHandler,
- TransactionLogRecoveryHandler tlogRecoveryHandler) throws Exception
+ TransactionLogRecoveryHandler tlogRecoveryHandler)
{
_stateManager.attainState(State.INITIALISED);
}
@Override
- public void activate() throws Exception
+ public void activate()
{
_stateManager.attainState(State.ACTIVATING);
_stateManager.attainState(State.ACTIVE);
@@ -104,32 +102,32 @@ public class
private AtomicLong _storeSizeIncrease = new AtomicLong();
@Override
- public StoreFuture commitTranAsync() throws AMQStoreException
+ public StoreFuture commitTranAsync()
{
QuotaMessageStore.this.storedSizeChange(_storeSizeIncrease.intValue());
return StoreFuture.IMMEDIATE_FUTURE;
}
@Override
- public void enqueueMessage(TransactionLogResource queue, EnqueueableMessage message) throws AMQStoreException
+ public void enqueueMessage(TransactionLogResource queue, EnqueueableMessage message)
{
_storeSizeIncrease.addAndGet(((MessageContentSource)message).getSize());
}
@Override
- public void dequeueMessage(TransactionLogResource queue, EnqueueableMessage message) throws AMQStoreException
+ public void dequeueMessage(TransactionLogResource queue, EnqueueableMessage message)
{
_storeSizeIncrease.addAndGet(-((MessageContentSource)message).getSize());
}
@Override
- public void commitTran() throws AMQStoreException
+ public void commitTran()
{
QuotaMessageStore.this.storedSizeChange(_storeSizeIncrease.intValue());
}
@Override
- public void abortTran() throws AMQStoreException
+ public void abortTran()
{
}
@@ -152,7 +150,7 @@ public class
}
@Override
- public void close() throws Exception
+ public void close()
{
if (_closed.compareAndSet(false, true))
{
diff --git a/java/systests/src/main/java/org/apache/qpid/server/store/SlowMessageStore.java b/java/systests/src/main/java/org/apache/qpid/server/store/SlowMessageStore.java
index cc0205085b..db1d5d9327 100644
--- a/java/systests/src/main/java/org/apache/qpid/server/store/SlowMessageStore.java
+++ b/java/systests/src/main/java/org/apache/qpid/server/store/SlowMessageStore.java
@@ -25,10 +25,10 @@ import java.util.Map;
import java.util.UUID;
import org.apache.log4j.Logger;
-import org.apache.qpid.AMQStoreException;
import org.apache.qpid.server.message.EnqueueableMessage;
import org.apache.qpid.server.message.ServerMessage;
import org.apache.qpid.server.model.VirtualHost;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
import java.nio.ByteBuffer;
import java.util.HashMap;
@@ -48,7 +48,7 @@ public class SlowMessageStore implements MessageStore, DurableConfigurationStore
// ***** MessageStore Interface.
- public void configureConfigStore(VirtualHost virtualHost, ConfigurationRecoveryHandler recoveryHandler) throws Exception
+ public void configureConfigStore(VirtualHost virtualHost, ConfigurationRecoveryHandler recoveryHandler)
{
_logger.info("Starting SlowMessageStore on Virtualhost:" + virtualHost.getName());
@@ -67,19 +67,34 @@ public class SlowMessageStore implements MessageStore, DurableConfigurationStore
if (messageStoreClass != null)
{
- Class<?> clazz = Class.forName(messageStoreClass);
-
- Object o = clazz.newInstance();
-
- if (!(o instanceof MessageStore))
+ try
+ {
+ Class<?> clazz = Class.forName(messageStoreClass);
+
+ Object o = clazz.newInstance();
+
+ if (!(o instanceof MessageStore))
+ {
+ throw new ClassCastException("Message store class must implement " + MessageStore.class + ". Class " + clazz +
+ " does not.");
+ }
+ _realStore = (MessageStore) o;
+ if(o instanceof DurableConfigurationStore)
+ {
+ _durableConfigurationStore = (DurableConfigurationStore)o;
+ }
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new ServerScopedRuntimeException("Unable to find message store class", e);
+ }
+ catch (InstantiationException e)
{
- throw new ClassCastException("Message store class must implement " + MessageStore.class + ". Class " + clazz +
- " does not.");
+ throw new ServerScopedRuntimeException("Unable to initialise message store class", e);
}
- _realStore = (MessageStore) o;
- if(o instanceof DurableConfigurationStore)
+ catch (IllegalAccessException e)
{
- _durableConfigurationStore = (DurableConfigurationStore)o;
+ throw new ServerScopedRuntimeException("Unable to access message store class", e);
}
}
_durableConfigurationStore.configureConfigStore(virtualHost, recoveryHandler);
@@ -152,12 +167,12 @@ public class SlowMessageStore implements MessageStore, DurableConfigurationStore
public void configureMessageStore(VirtualHost virtualHost, MessageStoreRecoveryHandler messageRecoveryHandler,
- TransactionLogRecoveryHandler tlogRecoveryHandler) throws Exception
+ TransactionLogRecoveryHandler tlogRecoveryHandler)
{
_realStore.configureMessageStore(virtualHost, messageRecoveryHandler, tlogRecoveryHandler);
}
- public void close() throws Exception
+ public void close()
{
doPreDelay("close");
_realStore.close();
@@ -171,7 +186,7 @@ public class SlowMessageStore implements MessageStore, DurableConfigurationStore
@Override
- public void create(UUID id, String type, Map<String, Object> attributes) throws AMQStoreException
+ public void create(UUID id, String type, Map<String, Object> attributes) throws StoreException
{
doPreDelay("create");
_durableConfigurationStore.create(id, type, attributes);
@@ -179,7 +194,7 @@ public class SlowMessageStore implements MessageStore, DurableConfigurationStore
}
@Override
- public void remove(UUID id, String type) throws AMQStoreException
+ public void remove(UUID id, String type) throws StoreException
{
doPreDelay("remove");
_durableConfigurationStore.remove(id, type);
@@ -187,7 +202,7 @@ public class SlowMessageStore implements MessageStore, DurableConfigurationStore
}
@Override
- public UUID[] removeConfiguredObjects(final UUID... objects) throws AMQStoreException
+ public UUID[] removeConfiguredObjects(final UUID... objects) throws StoreException
{
doPreDelay("remove");
UUID[] removed = _durableConfigurationStore.removeConfiguredObjects(objects);
@@ -196,7 +211,7 @@ public class SlowMessageStore implements MessageStore, DurableConfigurationStore
}
@Override
- public void update(UUID id, String type, Map<String, Object> attributes) throws AMQStoreException
+ public void update(UUID id, String type, Map<String, Object> attributes) throws StoreException
{
doPreDelay("update");
_durableConfigurationStore.update(id, type, attributes);
@@ -204,7 +219,7 @@ public class SlowMessageStore implements MessageStore, DurableConfigurationStore
}
@Override
- public void update(ConfiguredObjectRecord... records) throws AMQStoreException
+ public void update(ConfiguredObjectRecord... records) throws StoreException
{
doPreDelay("update");
_durableConfigurationStore.update(records);
@@ -212,7 +227,7 @@ public class SlowMessageStore implements MessageStore, DurableConfigurationStore
}
@Override
- public void update(boolean createIfNecessary, ConfiguredObjectRecord... records) throws AMQStoreException
+ public void update(boolean createIfNecessary, ConfiguredObjectRecord... records) throws StoreException
{
doPreDelay("update");
_durableConfigurationStore.update(createIfNecessary, records);
@@ -258,7 +273,6 @@ public class SlowMessageStore implements MessageStore, DurableConfigurationStore
}
public void enqueueMessage(TransactionLogResource queue, EnqueueableMessage message)
- throws AMQStoreException
{
doPreDelay("enqueueMessage");
_underlying.enqueueMessage(queue, message);
@@ -266,7 +280,6 @@ public class SlowMessageStore implements MessageStore, DurableConfigurationStore
}
public void dequeueMessage(TransactionLogResource queue, EnqueueableMessage message)
- throws AMQStoreException
{
doPreDelay("dequeueMessage");
_underlying.dequeueMessage(queue, message);
@@ -274,7 +287,6 @@ public class SlowMessageStore implements MessageStore, DurableConfigurationStore
}
public void commitTran()
- throws AMQStoreException
{
doPreDelay("commitTran");
_underlying.commitTran();
@@ -282,7 +294,6 @@ public class SlowMessageStore implements MessageStore, DurableConfigurationStore
}
public StoreFuture commitTranAsync()
- throws AMQStoreException
{
doPreDelay("commitTran");
StoreFuture future = _underlying.commitTranAsync();
@@ -291,27 +302,25 @@ public class SlowMessageStore implements MessageStore, DurableConfigurationStore
}
public void abortTran()
- throws AMQStoreException
{
doPreDelay("abortTran");
_underlying.abortTran();
doPostDelay("abortTran");
}
- public void removeXid(long format, byte[] globalId, byte[] branchId) throws AMQStoreException
+ public void removeXid(long format, byte[] globalId, byte[] branchId)
{
_underlying.removeXid(format, globalId, branchId);
}
public void recordXid(long format, byte[] globalId, byte[] branchId, Record[] enqueues, Record[] dequeues)
- throws AMQStoreException
{
_underlying.recordXid(format, globalId, branchId, enqueues, dequeues);
}
}
@Override
- public void activate() throws Exception
+ public void activate()
{
_realStore.activate();
}