Permalink
Browse files

Unregistering previously registered MBeans if a register() for the sa…

…me name is encountered (https://issues.jboss.org/browse/JGRP-1392)
  • Loading branch information...
1 parent 65e7a85 commit e97c53571694628bfafce2733857ad75ad66b703 Bela Ban committed Nov 25, 2011
Showing with 11 additions and 0 deletions.
  1. +11 −0 src/org/jgroups/jmx/JmxConfigurator.java
@@ -162,6 +162,17 @@ private static void internalRegister(Object obj, MBeanServer server, String name
try {
ObjectName objName = getObjectName(obj, name);
+ if(server.isRegistered(objName)) {
+ if(log.isWarnEnabled())
+ log.warn("unregistering already registered MBean: " + objName);
+ try {
+ server.unregisterMBean(objName);
+ }
+ catch(InstanceNotFoundException e) {
+ log.error("failed to unregister MBean " + e.getMessage());
+ }
+ }
+
ResourceDMBean res = new ResourceDMBean(obj);
server.registerMBean(res, objName);
} catch (InstanceAlreadyExistsException e) {

0 comments on commit e97c535

Please sign in to comment.