[jboss-cvs] JBossAS SVN: r109231 - projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Nov 10 11:28:09 EST 2010


Author: pferraro
Date: 2010-11-10 11:28:09 -0500 (Wed, 10 Nov 2010)
New Revision: 109231

Modified:
   projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/DefaultCacheContainerRegistry.java
Log:
Fix NPE during cache mbean unregistration.

Modified: projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/DefaultCacheContainerRegistry.java
===================================================================
--- projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/DefaultCacheContainerRegistry.java	2010-11-10 16:19:44 UTC (rev 109230)
+++ projects/cluster/ha-server-ispn/trunk/src/main/java/org/jboss/ha/ispn/DefaultCacheContainerRegistry.java	2010-11-10 16:28:09 UTC (rev 109231)
@@ -322,7 +322,7 @@
    @CacheStarted
    public void cacheStarted(CacheStartedEvent event)
    {
-      this.log("Started", event.getCacheName(), event.getCacheManager());
+      log("Started", event.getCacheName(), event.getCacheManager());
    }
    
    @CacheStopped
@@ -331,18 +331,21 @@
       String cacheName = event.getCacheName();
       EmbeddedCacheManager container = event.getCacheManager();
       
-      this.log("Stopped", cacheName, container);
+      log("Stopped", cacheName, container);
 
       // Infinispan does not unregister cache mbean when cache stops (only when cache manager is stopped), so do it now to avoid classloader leaks
       Configuration configuration = container.defineConfiguration(cacheName, new Configuration());
       if (configuration.isExposeJmxStatistics())
       {
-         GlobalConfiguration global = configuration.getGlobalConfiguration();
+         GlobalConfiguration global = container.getGlobalConfiguration();
+         String domain = global.getJmxDomain();
          String jmxCacheName = String.format("%s(%s)", cacheName, configuration.getCacheModeString().toLowerCase(Locale.ENGLISH));
+         String containerName = global.getCacheManagerName();
+         
          try
          {
             // Fragile code alert!
-            ObjectName name = ObjectName.getInstance(String.format("%s:%s,%s=%s,manager=%s,%s=%s", global.getJmxDomain(), CacheJmxRegistration.CACHE_JMX_GROUP, ComponentsJmxRegistration.NAME_KEY, ObjectName.quote(jmxCacheName), ObjectName.quote(global.getCacheManagerName()), ComponentsJmxRegistration.COMPONENT_KEY, "Cache"));
+            ObjectName name = ObjectName.getInstance(String.format("%s:%s,%s=%s,manager=%s,%s=%s", domain, CacheJmxRegistration.CACHE_JMX_GROUP, ComponentsJmxRegistration.NAME_KEY, ObjectName.quote(jmxCacheName), ObjectName.quote(containerName), ComponentsJmxRegistration.COMPONENT_KEY, "Cache"));
 
             if (this.server.isRegistered(name))
             {
@@ -357,7 +360,7 @@
       }
    }
    
-   private void log(String event, String cacheName, EmbeddedCacheManager container)
+   private static void log(String event, String cacheName, EmbeddedCacheManager container)
    {
       logger.info(String.format("%s \"%s\" cache from \"%s\" container", event, cacheName, container.getGlobalConfiguration().getCacheManagerName()));
    }



More information about the jboss-cvs-commits mailing list