Patches item #642867, was opened at 2002-11-23 22:23
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376687&aid=642867&group_id=22866

Category: JBossServer
Group: v3.0 Rabbit Hole
Status: Open
Resolution: None
Priority: 5
Submitted By: Laurent Etiemble (letiemble)
Assigned to: Nobody/Anonymous (nobody)
Summary: Patch for Bug in RMI Connector

Initial Comment:
Hi,

I think there is a bug in the RMIConnectorImpl class 
related to the management of the Client Notification 
Listener list.

When a RMI notification listener is registered, a new 
MBean is created (i.e. JMX:id=xxxxxxxx,type=listener).
When the listener is unregistered, the MBean is 
destroyed.
If you repeat the operation a second time with the same 
parameter (same target MBean and same Notification 
Listener), the MBean is created but not destroyed after 
the unregistration of the listener.

In org.jboss.jmx.connector.rmi.RMIConnectorImpl, the 
listeners list is correctly managed when an add occured, 
but there is no removal when a remove occured.

I can't provide a diff, so here is the method to change.
I have also provide a test to reproduce the bug.

Regards

Patch to apply :
============

   public void removeNotificationListener(
      ObjectName pName,
      NotificationListener pListener
   ) throws
      InstanceNotFoundException,
      ListenerNotFoundException
   {
      ClientNotificationListener lCheck = new 
SearchClientNotificationListener( pName, pListener );
      int i = mListeners.indexOf( lCheck );
      if( i >= 0 ) {
         ClientNotificationListener lListener = 
(ClientNotificationListener) mListeners.get( i );
         lListener.removeNotificationListener( this );

### Line to add ###
         mListeners.remove(i);
###
      }
   }


Program to reproduce :
=================

import java.util.Vector;
import javax.management.Notification;
import javax.management.NotificationListener;
import javax.management.ObjectName;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;

import org.jboss.jmx.adaptor.rmi.RMIAdaptor;
import org.jboss.jmx.connector.rmi.RMIConnectorImpl;

public class Test
{
   public static void main(String[] args)
      throws Exception
   {
      InitialContext context = new InitialContext();
      Object ref = context.lookup("jmx:<yourhost>:rmi");

      RMIAdaptor adaptor = (RMIAdaptor) 
PortableRemoteObject.narrow(ref,
RMIAdaptor.class);
      RMIConnectorImpl connector = new 
RMIConnectorImpl(adaptor);

      System.out.println("Got a connector " + connector);

      NotificationListener listener =
         new NotificationListener()
         {
            public void handleNotification(Notification 
notification, Object
object)
            {
               System.out.println("Got a notification " + 
notification + "
from " + object);
            }
         };

      ObjectName on = new
ObjectName
("JMImplementation:type=MBeanServerDelegate");
      connector.addNotificationListener(on, listener, 
null, "DUMMY");
      System.out.println("Listener registered");
      connector.removeNotificationListener(on, listener);
      System.out.println("Listener unregistered");

      connector.addNotificationListener(on, listener, 
null, "DUMMY");
      System.out.println("Listener registered");
      connector.removeNotificationListener(on, listener);
      System.out.println("Listener unregistered");
   }
}


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376687&aid=642867&group_id=22866


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to