You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rg...@apache.org on 2007/09/21 13:06:43 UTC
svn commit: r578058 -
/incubator/qpid/branches/M2.1/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java
Author: rgreig
Date: Fri Sep 21 04:06:40 2007
New Revision: 578058
URL: http://svn.apache.org/viewvc?rev=578058&view=rev
Log:
QPID-606: synchronize retrieval of application registry to avoid race conditions. This was
particularly affecting systests which use the in-VM broker.
Modified:
incubator/qpid/branches/M2.1/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java
Modified: incubator/qpid/branches/M2.1/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java?rev=578058&r1=578057&r2=578058&view=diff
==============================================================================
--- incubator/qpid/branches/M2.1/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java (original)
+++ incubator/qpid/branches/M2.1/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java Fri Sep 21 04:06:40 2007
@@ -137,28 +137,31 @@
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;
}
}