diff options
author | Robert Gemmell <robbie@apache.org> | 2013-05-04 21:33:32 +0000 |
---|---|---|
committer | Robert Gemmell <robbie@apache.org> | 2013-05-04 21:33:32 +0000 |
commit | c7f20a1b639fcc66a4928c44c7bdd36d23ac8b47 (patch) | |
tree | 26fc5080e694a78fff3bedce81bdcb907a34aac8 | |
parent | 12cd8d1d7dbbc6e68a44c94dcadd6e1652002332 (diff) | |
download | qpid-python-c7f20a1b639fcc66a4928c44c7bdd36d23ac8b47.tar.gz |
QPID-4390: ensure the _messageStore field is populated prior configuring the store to ensure it is set before use by the listener during the asynchronous HA store activation
merged from trunk r1479172
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/0.22@1479182 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java index 02852d1a70..b39f975c28 100644 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java @@ -146,7 +146,9 @@ public class VirtualHostImpl implements VirtualHost, IConnectionRegistry.Registr _bindingFactory = new BindingFactory(this); - _messageStore = configureMessageStore(hostConfig); + _messageStore = initialiseMessageStore(hostConfig); + + configureMessageStore(hostConfig); activateNonHAMessageStore(); @@ -260,29 +262,21 @@ public class VirtualHostImpl implements VirtualHost, IConnectionRegistry.Registr return _houseKeepingTasks.getActiveCount(); } - - private MessageStore initialiseMessageStore(final String messageStoreClass) throws Exception - { - final Class<?> clazz = Class.forName(messageStoreClass); - final Object o = clazz.newInstance(); - - if (!(o instanceof MessageStore)) - { - throw new ClassCastException("Message store class must implement " + MessageStore.class + - ". Class " + clazz + " does not."); - } - - final MessageStore messageStore = (MessageStore) o; - return messageStore; - } - - private MessageStore configureMessageStore(VirtualHostConfiguration hostConfig) throws Exception + private MessageStore initialiseMessageStore(VirtualHostConfiguration hostConfig) throws Exception { String storeType = hostConfig.getConfig().getString("store.type"); MessageStore messageStore = null; if (storeType == null) { - messageStore = initialiseMessageStore(hostConfig.getMessageStoreClass()); + 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); + } + + messageStore = (MessageStore) o; } else { @@ -301,11 +295,6 @@ public class VirtualHostImpl implements VirtualHost, IConnectionRegistry.Registr messageStore.addEventListener(new AfterInitialisationListener(), Event.AFTER_INIT); } - VirtualHostConfigRecoveryHandler recoveryHandler = new VirtualHostConfigRecoveryHandler(this); - - messageStore.configureConfigStore(getName(), recoveryHandler, hostConfig.getStoreConfiguration()); - messageStore.configureMessageStore(getName(), recoveryHandler, recoveryHandler, hostConfig.getStoreConfiguration()); - return messageStore; } @@ -317,6 +306,14 @@ public class VirtualHostImpl implements VirtualHost, IConnectionRegistry.Registr } } + private void configureMessageStore(VirtualHostConfiguration hostConfig) throws Exception + { + VirtualHostConfigRecoveryHandler recoveryHandler = new VirtualHostConfigRecoveryHandler(this); + + _messageStore.configureConfigStore(getName(), recoveryHandler, hostConfig.getStoreConfiguration()); + _messageStore.configureMessageStore(getName(), recoveryHandler, recoveryHandler, hostConfig.getStoreConfiguration()); + } + private void initialiseModel(VirtualHostConfiguration config) throws ConfigurationException, AMQException { _logger.debug("Loading configuration for virtualhost: " + config.getName()); |