Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6218920
Votes 0
Synopsis API bug - impossible to delete last MBeanServerForwarder on a connector
Category jmx:classes
Reported Against
Release Fixed 7(b34)
State 10-Fix Delivered, request for enhancement
Priority: 4-Low
Related Bugs
Submit Date 19-JAN-2005
Description
There is an asymmetry in the JMXConnectorServer API that makes it impossible
to delete the last MBeanServerForwarder instance attached to that ConnectorServer.

One adds a new MBeanServerForwarder instance using

cs.setMBeanServerForwarder(mbsf)

This inserts the mbsf between the cs and an MBeanServer.

But one cannot delete the reference to a singleton MBeanServerForwarder since there is no API to remove the reference to it.

cs.setMBeanServer()

or cs.deleteMBeanServerForwarder(mbsf)

  xxxxx@xxxxx   2005-1-19 11:56:06 GMT
Work Around
It's possible to put an otherwise empty MBeanServerForwarder in place before
pushing any removable MBeanServerForwarder instances into the list, this
way it's always possible to remove those mbsf that you wish to, whilst leaving
the empty mbsf in place.

Note that if such a empty MBSF is to be put in place it needs to be available
in a classloader that doesn't need to be garbage collected when unloading
the significant MBSF.

For info, JDMK provides a suitable class to use as an empty MBeanServerForwarder, but this is also trivial to code.


  xxxxx@xxxxx   2005-1-19 11:56:06 GMT

If you need a dynamically-evolving list of forwarders, you should add a single forwarder that maintains its own list.
  xxxxx@xxxxx   2005-05-03 14:00:31 GMT
Evaluation
As mentioned in the Description, the specific problem is when there is exactly one MBeanServerForwarder between the Connector Server and the final MBeanServer.  Since the only method you have is connectorServer.setMBeanServerForwarder(MBeanServerForwarder mbsf), you cannot call setMBeanServerForwarder(mbeanServer).  An MBeanServer is not an MBeanServerForwarder.

The intent of the current design is that a ConnectorServer is always attached to the same MBeanServer, so we do not want to add a connectorServer.setMBeanServer, which would seem to allow you to attach to a different MBeanServer.  Instead, the suggestion is to add one of the following:
connectorServer.deleteFirstMBeanServerForwarder()
connectorServer.deleteAllMBeanServerForwarders()
connectorServer.deleteMBeanServerForwarder(MBeanServerForwarder mbsf)

The last of these methods would traverse the list of forwarders until it found mbsf and do the necessary surgery to remove it, potentially attaching the ConnectorServer to the final MBeanServer if mbsf was the only forwarder.

We cannot add new methods to the MBean interface ConnectorServerMBean without potentially breaking source compatibility for existing code, so either we need to create a subinterface ConnectorServer2MBean (or whatever), or the new deleteWhatever method will not be accessible through the MBean interface.
  xxxxx@xxxxx   2005-1-19 13:57:22 GMT

Another, simpler solution would be just to say that a null argument to JMXConnectorServer.setMBeanServerForwarder is allowed, and causes the MBeanServerForwarder chain to be cleared so that JMXConnectorServer.getMBeanServer returns the MBeanServer object at the end of the chain.  Thus, to remove the first forwarder in the chain:
    JMXConnectorServer cs;
    MBeanServer mbs1 = cs.getMBeanServer();
    if (!(mbs1 instanceof MBeanServerForwarder)) throw ...;
    MBeanServerForwarder mbsf = (MBeanServerForwarder) mbs1;
    MBeanServer mbs2 = mbsf.getMBeanServer();
    if (mbs2 instanceof MBeanServerForwarder)
        cs.setMBeanServerForwarder((MBeanServerForwarder) mbs2);
    else
        cs.setMBeanServerForwarder(null);

This change could be made in Mustang.
  xxxxx@xxxxx   2005-1-21 08:40:12 GMT

In fact this method is only intended to add a new forwarder.  As specified, it cannot be used to remove a forwarder, whether or not it is the last forwarder.  I am transforming this into a Request For Enhancement (not a bug) for a way to remove a forwarder.
  xxxxx@xxxxx   2005-05-03 14:00:31 GMT
Version 2.0 of the JMX API will add a method JMXConnectorServer.removeMBeanServerForwarder.
Posted Date : 2008-06-18 16:33:55.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang