Mantis - Resin
Viewing Issue Advanced Details
1390 major always 10-05-06 09:19 10-31-06 14:25
maltem  
ferg  
urgent  
closed 3.0.21  
fixed  
none    
none 3.0.22  
0001390: Issues with registering Mbeans
After upgrading to 3.0.21, we started receiving the following exception for one of our MBeans:

2006-10-02 14:05:42 PDT] <SystemStartup> System - ERROR: Problem create HTTP Connector.
Exception: javax.management.NotCompliantMBeanException: javax.management.IntrospectionException: bad getter arg count
        at com.caucho.jmx.IntrospectionMBean.introspect(IntrospectionMBean.java)
        at com.caucho.jmx.IntrospectionMBean.<init>(IntrospectionMBean.java:95)
        at com.caucho.jmx.IntrospectionMBean.<init>(IntrospectionMBean.java:75)
        at com.caucho.jmx.AbstractMBeanServer.createMBean(AbstractMBeanServer.java:459)
        at com.caucho.jmx.AbstractMBeanServer.registerMBean(AbstractMBeanServer.java:430)
        at com.ec.spine.jmx.JmxConnectorConfig.createHttpConnector(JmxConnectorConfig.java:331)
        at com.ec.spine.servlets.SystemServlet.handleJmxConnectors(SystemServlet.java:607)
        at com.ec.spine.servlets.SystemServlet.startup(SystemServlet.java:577)
        at com.ec.spine.servlets.SystemServlet.access$000(SystemServlet.java:66)
        at com.ec.spine.servlets.SystemServlet$1.run(SystemServlet.java:455)
Caused by: javax.management.IntrospectionException: bad getter arg count
        at javax.management.MBeanAttributeInfo.attributeType(MBeanAttributeInfo.java:236)
        at javax.management.MBeanAttributeInfo.<init>(MBeanAttributeInfo.java:122)
        ... 10 more
One of our engineers has tracked down the problem, please find his analysis below.
Please let us know when we can expect this issue to be resolved.

Looks like a bug was instroduced in com.caucho.jmx.IntrospectionMBean. In the introspect(..) method there is a piece of code that handles cases where the class has a setter without a getter. In that scenario the code adds a attribute with null getter method. The MBeanAttributeInfo constructor is called with 4 attributes. It expects a getter method as 3rd attribute? and the implementation is passing in the setter which takes one argument? getters are not supposed have any arguments? hence \"bad getter arg count\" exception.

Here is the code from 3.0.21 and 3.0.14(version on my local) for comparision
-----------------------------------------
com.caucho.jmx.IntrospectionMBean.java:.. Introspect(..) - lines 500-524

        else if (methodName.startsWith(\"set\") && args.length == 1) {
          String name = methodName.substring(3);

          Method getter = getGetter(methods, name, args[0]);

          if (getter == null) {
            String attributeName;

            if (isLowercaseAttributeNames) {
              StringBuilder builder = new StringBuilder(name);
              builder.setCharAt(0, Character.toLowerCase(builder.charAt(0)));
              attributeName = builder.toString();
            }
            else
              attributeName = name;

        if (attributes.get(attributeName) == null) {
          attributes.put(attributeName,
                 new MBeanAttributeInfo(attributeName,
                            getDescription(method),
                            method,
                            null));
        }
      }
    }
-----------------------------------------------------------
javax.management.MBeanAttributeInfo : constructor code

    public MBeanAttributeInfo(String name,
                  String description,
                  Method getter,
                  Method setter) throws IntrospectionException {
    this(name,
         attributeType(getter, setter), --->> Exception is thrown in this method.
         description,
         (getter != null),
         (setter != null),
         isIs(getter));
    }
----------------------------------------------------

I compared it with the src from the version I am running.. 3.0.14:

Code from version 3.0.14:
-----------------------------------------
com.caucho.jmx.IntrospectionMBean.java:.. Introspect(..) - lines 355-362


    else if (methodName.startsWith(\"set\") && args.length == 1) {
      String name = methodName.substring(3);

      Method getter = getGetter(methods, name, args[0]);

      if (getter == null)
        attributes.add(new MBeanAttributeInfo(name, name, null, method)); --->> notice order of parameters.
    }
---------------------------------------------------

There are no notes attached to this issue.