MBeanExporter does not log warnings for manually unregistered MBeans

Issue: SPR-9451
This commit is contained in:
Juergen Hoeller 2013-01-18 14:43:11 +01:00
parent 721fa9db6a
commit 3dd817585b
1 changed files with 5 additions and 4 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,6 +16,7 @@
package org.springframework.jmx.support; package org.springframework.jmx.support;
import java.util.Collections;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.Set; import java.util.Set;
import javax.management.InstanceAlreadyExistsException; import javax.management.InstanceAlreadyExistsException;
@ -112,7 +113,7 @@ public class MBeanRegistrationSupport {
/** /**
* The beans that have been registered by this exporter. * The beans that have been registered by this exporter.
*/ */
protected final Set<ObjectName> registeredBeans = new LinkedHashSet<ObjectName>(); private final Set<ObjectName> registeredBeans = Collections.synchronizedSet(new LinkedHashSet<ObjectName>());
/** /**
* The policy used when registering an MBean and finding that it already exists. * The policy used when registering an MBean and finding that it already exists.
@ -228,10 +229,9 @@ public class MBeanRegistrationSupport {
* Unregisters all beans that have been registered by an instance of this class. * Unregisters all beans that have been registered by an instance of this class.
*/ */
protected void unregisterBeans() { protected void unregisterBeans() {
for (ObjectName objectName : this.registeredBeans) { for (ObjectName objectName : new LinkedHashSet<ObjectName>(this.registeredBeans)) {
doUnregister(objectName); doUnregister(objectName);
} }
this.registeredBeans.clear();
} }
/** /**
@ -257,6 +257,7 @@ public class MBeanRegistrationSupport {
logger.error("Could not unregister MBean [" + objectName + "]", ex); logger.error("Could not unregister MBean [" + objectName + "]", ex);
} }
} }
this.registeredBeans.remove(objectName);
} }
/** /**