This is an automated email from the ASF dual-hosted git repository. rmaucher pushed a commit to branch 11.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 0e86835b5153a129ae11274a4a28c884f5d5c847 Author: opencode <[email protected]> AuthorDate: Wed Oct 7 14:09:02 2026 +0200 Resolve the modeler type of model MBeans in the MBeanDumper The check that replaces the class name of a model MBean with the type of its managed resource compared the class name against the class name of the commons modeler BaseModelMBean, which has not been the base class in this codebase since the modeler was forked. The branch therefore never executed and every MBean whose descriptor omits an explicit className, such as the MBeanFactory registered by the Server, was dumped with modelerType set to the base class name instead of the actual managed resource class. Compare against the current base class org.apache.tomcat.util.modeler.BaseModelMBean so the modelerType attribute is used as intended. Add a test that starts embedded Tomcat and checks the dumped modelerType of the MBeanFactory MBean. --- java/org/apache/catalina/mbeans/MBeanDumper.java | 2 +- .../apache/catalina/mbeans/TestMBeanDumper.java | 48 ++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/java/org/apache/catalina/mbeans/MBeanDumper.java b/java/org/apache/catalina/mbeans/MBeanDumper.java index 5812f9f16c..3230afffd9 100644 --- a/java/org/apache/catalina/mbeans/MBeanDumper.java +++ b/java/org/apache/catalina/mbeans/MBeanDumper.java @@ -76,7 +76,7 @@ public class MBeanDumper { MBeanInfo minfo = mbeanServer.getMBeanInfo(oname); // can't be null - I think String code = minfo.getClassName(); - if ("org.apache.commons.modeler.BaseModelMBean".equals(code)) { + if ("org.apache.tomcat.util.modeler.BaseModelMBean".equals(code)) { code = (String) mbeanServer.getAttribute(oname, "modelerType"); } buf.append("modelerType: "); diff --git a/test/org/apache/catalina/mbeans/TestMBeanDumper.java b/test/org/apache/catalina/mbeans/TestMBeanDumper.java new file mode 100644 index 0000000000..8a08161621 --- /dev/null +++ b/test/org/apache/catalina/mbeans/TestMBeanDumper.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.catalina.mbeans; + +import java.util.Collections; +import java.util.Set; + +import javax.management.MBeanServer; +import javax.management.ObjectName; + +import org.junit.Assert; +import org.junit.Test; + +import org.apache.catalina.startup.Tomcat; +import org.apache.catalina.startup.TomcatBaseTest; +import org.apache.tomcat.util.modeler.Registry; + +public class TestMBeanDumper extends TomcatBaseTest { + + @Test + public void testDumpResolvesDefaultModelerType() throws Exception { + Tomcat tomcat = getTomcatInstance(); + tomcat.start(); + + MBeanServer server = Registry.getRegistry(null).getMBeanServer(); + ObjectName oname = new ObjectName("Tomcat:type=MBeanFactory"); + Set<ObjectName> names = Collections.singleton(oname); + Assert.assertTrue(server.isRegistered(oname)); + + String dump = MBeanDumper.dumpBeans(server, names); + + Assert.assertTrue(dump.contains("modelerType: org.apache.catalina.mbeans.MBeanFactory")); + } +} --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
