Skip to content

Commit

Permalink
MBeanExporter does not log warnings for manually unregistered MBeans
Browse files Browse the repository at this point in the history
Issue: SPR-9451
  • Loading branch information
jhoeller committed Jan 18, 2013
1 parent eb492ed commit 0c45f17
Showing 1 changed file with 11 additions and 10 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,6 +16,7 @@

package org.springframework.jmx.support;

import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;
import javax.management.InstanceAlreadyExistsException;
Expand Down Expand Up @@ -92,19 +93,19 @@ public class MBeanRegistrationSupport {
private static final Constants constants = new Constants(MBeanRegistrationSupport.class);

/**
* <code>Log</code> instance for this class.
* {@code Log} instance for this class.
*/
protected final Log logger = LogFactory.getLog(getClass());

/**
* The <code>MBeanServer</code> instance being used to register beans.
* The {@code MBeanServer} instance being used to register beans.
*/
protected MBeanServer server;

/**
* The beans that have been registered by this exporter.
*/
protected final Set<ObjectName> registeredBeans = new LinkedHashSet<ObjectName>();
protected final Set<ObjectName> registeredBeans = Collections.synchronizedSet(new LinkedHashSet<ObjectName>());

/**
* The action take when registering an MBean and finding that it already exists.
Expand All @@ -114,16 +115,16 @@ public class MBeanRegistrationSupport {


/**
* Specify the <code>MBeanServer</code> instance with which all beans should
* be registered. The <code>MBeanExporter</code> will attempt to locate an
* existing <code>MBeanServer</code> if none is supplied.
* Specify the {@code MBeanServer} instance with which all beans should
* be registered. The {@code MBeanExporter} will attempt to locate an
* existing {@code MBeanServer} if none is supplied.
*/
public void setServer(MBeanServer server) {
this.server = server;
}

/**
* Return the <code>MBeanServer</code> that the beans will be registered with.
* Return the {@code MBeanServer} that the beans will be registered with.
*/
public final MBeanServer getServer() {
return this.server;
Expand Down Expand Up @@ -205,10 +206,9 @@ else if (this.registrationBehavior == REGISTRATION_REPLACE_EXISTING) {
* Unregisters all beans that have been registered by an instance of this class.
*/
protected void unregisterBeans() {
for (ObjectName objectName : this.registeredBeans) {
for (ObjectName objectName : new LinkedHashSet<ObjectName>(this.registeredBeans)) {
doUnregister(objectName);
}
this.registeredBeans.clear();
}

/**
Expand All @@ -234,6 +234,7 @@ protected void doUnregister(ObjectName objectName) {
logger.error("Could not unregister MBean [" + objectName + "]", ex);
}
}
this.registeredBeans.remove(objectName);
}

/**
Expand Down

0 comments on commit 0c45f17

Please sign in to comment.