This is an automated email from the ASF dual-hosted git repository.
jbonofre pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq.git
The following commit(s) were added to refs/heads/main by this push:
new 7b502c62c0 AMQ-9843 Handle InstanceNotFoundException during MBean
unregistration to avoid errors on shutdown (#1635)
7b502c62c0 is described below
commit 7b502c62c02d515f07eb45bebc8e4e58e74debcc
Author: Jean-Louis Monteiro <[email protected]>
AuthorDate: Sun Feb 1 08:31:43 2026 +0100
AMQ-9843 Handle InstanceNotFoundException during MBean unregistration to
avoid errors on shutdown (#1635)
---
.../activemq/broker/jmx/ManagementContext.java | 24 ++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git
a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java
b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java
index 7ef4529308..28c6f8c3d0 100644
---
a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java
+++
b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java
@@ -203,10 +203,16 @@ public class ManagementContext implements Service {
// unregister the mbeans we have registered
if (mbeanServer != null) {
for (Map.Entry<ObjectName, ObjectName> entry :
registeredMBeanNames.entrySet()) {
- ObjectName actualName = entry.getValue();
+ final ObjectName actualName = entry.getValue();
if (actualName != null &&
beanServer.isRegistered(actualName)) {
- LOG.debug("Unregistering MBean {}", actualName);
- mbeanServer.unregisterMBean(actualName);
+ try {
+ LOG.debug("Unregistering MBean {}", actualName);
+ mbeanServer.unregisterMBean(actualName);
+ } catch (javax.management.InstanceNotFoundException e)
{
+ // Ignore - the MBean was already unregistered
(likely by advisory cleanup)
+ // This is a benign race condition during shutdown
+ LOG.trace("MBean already unregistered: {}",
actualName);
+ }
}
}
}
@@ -449,10 +455,16 @@ public class ManagementContext implements Service {
* Unregister an MBean
*/
public void unregisterMBean(ObjectName name) throws JMException {
- ObjectName actualName = this.registeredMBeanNames.get(name);
+ final ObjectName actualName = this.registeredMBeanNames.get(name);
if (beanServer != null && actualName != null &&
beanServer.isRegistered(actualName) && this.registeredMBeanNames.remove(name)
!= null) {
- LOG.debug("Unregistering MBean {}", actualName);
- beanServer.unregisterMBean(actualName);
+ try {
+ LOG.debug("Unregistering MBean {}", actualName);
+ beanServer.unregisterMBean(actualName);
+ } catch (javax.management.InstanceNotFoundException e) {
+ // Ignore - the MBean was already unregistered (race condition
during concurrent cleanup)
+ // This is benign since the MBean is already gone, which is
what we wanted
+ LOG.trace("MBean already unregistered: {}", actualName);
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact