diff options
| author | Robert Greig <rgreig@apache.org> | 2007-09-21 11:06:40 +0000 |
|---|---|---|
| committer | Robert Greig <rgreig@apache.org> | 2007-09-21 11:06:40 +0000 |
| commit | 1e1dcabb4adb31b81834b93216c39060286c245e (patch) | |
| tree | e2d4c7f23c09e19cadae88bd6cdb13ef7cbe30de /java/broker | |
| parent | d6d4907f93de304e21878881752c6c7b4cde0135 (diff) | |
| download | qpid-python-1e1dcabb4adb31b81834b93216c39060286c245e.tar.gz | |
QPID-606: synchronize retrieval of application registry to avoid race conditions. This was
particularly affecting systests which use the in-VM broker.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/M2.1@578058 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/broker')
| -rw-r--r-- | java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java b/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java index 89f0b7b39d..22fa0fab23 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java +++ b/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java @@ -137,29 +137,32 @@ public abstract class ApplicationRegistry implements IApplicationRegistry public static IApplicationRegistry getInstance(int instanceID) { - IApplicationRegistry instance = _instanceMap.get(instanceID); - - if (instance == null) + synchronized (IApplicationRegistry.class) { - try + IApplicationRegistry instance = _instanceMap.get(instanceID); + + if (instance == null) { - _logger.info("Creating DEFAULT_APPLICATION_REGISTRY: " + _APPLICATION_REGISTRY + " : Instance:" + instanceID); - IApplicationRegistry registry = (IApplicationRegistry) Class.forName(_APPLICATION_REGISTRY).getConstructor((Class[]) null).newInstance((Object[]) null); - ApplicationRegistry.initialise(registry, instanceID); - _logger.info("Initialised Application Registry:" + instanceID); - return registry; + try + { + _logger.info("Creating DEFAULT_APPLICATION_REGISTRY: " + _APPLICATION_REGISTRY + " : Instance:" + instanceID); + IApplicationRegistry registry = (IApplicationRegistry) Class.forName(_APPLICATION_REGISTRY).getConstructor((Class[]) null).newInstance((Object[]) null); + ApplicationRegistry.initialise(registry, instanceID); + _logger.info("Initialised Application Registry:" + instanceID); + return registry; + } + catch (Exception e) + { + _logger.error("Error configuring application: " + e, e); + //throw new AMQBrokerCreationException(instanceID, "Unable to create Application Registry instance " + instanceID); + throw new RuntimeException("Unable to create Application Registry", e); + } } - catch (Exception e) + else { - _logger.error("Error configuring application: " + e, e); - //throw new AMQBrokerCreationException(instanceID, "Unable to create Application Registry instance " + instanceID); - throw new RuntimeException("Unable to create Application Registry", e); + return instance; } } - else - { - return instance; - } } public void close() throws Exception |
