groovy
  1. groovy
  2. GROOVY-2807

GroovyMBean does not support the use of overloaded MBean operations that have the same number of parameters

    Details

    • Type: Bug Bug
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: JMX
    • Labels:
      None
    • Number of attachments :
      1

      Description

      I've been using groovy.util.GroovyMBean to access MBeans running on the JBoss 4 server. Some of the operations/methods of the MBeans are overloaded, e.g.:

      void redeploy(java.lang.String url)
      void redeploy(java.net.URL url)
      void redeploy(org.jboss.deployment.DeploymentInfo sdi)
      

      Currently it's impossible to invoke the first 2.

      The problem is, when the GroovyMBean is constructed it stores a signature for each operation from its specified MBean in a HashMap, using the operation name and the number of parameters as its key. Later, when the invokeMethod method is invoked, it uses the method name and the number of parameters to retrieve the signature to invoke the operation on the MBean. Thus for overloaded operations with the same number of parameters, only the last operation found will be stored in the HashMap.

      If another variant of the operation is invoked on the GroovyMBean then an incorrect signature will be passed to the MBeanServer which results in an exception occurring on the server.

      The fix I've used (suggested by a comment in the source code) is to construct a key out of the name of the operation and the sum of the hash codes of the class names of the parameters.

      The problem is, this required 2 new createOperationKey methods:

      String createOperationKey(MBeanOperationInfo opInfo)
      String createOperationKey(String method, Object[] args)
      

      The first is invoked by the constructor, and the second that is invoked by the invokeMethod method. The original createOperationKey method is removed. This might create backwards compatibility problems.

      I've included an adjusted GroovyMBean class, although temporarily in a new package (groovy.util.adjusted).

      This issue is an extension of issue GROOVY-1291

        Issue Links

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              Meyrick Kirby
            • Votes:
              4 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: