mx4j(3.0.1) bug - removeNotificationListener

"Rottgardt, Jens (GOB-2/3)" <[email protected]>
Newsgroups gmane.comp.java.mx4j.devel,gmane.comp.java.mx4j.user
Message-ID <[email protected]>
Hello,

I think I have found a bug in the removeNotifcationListener methods of th
ClientInvoker class:

This bug makes it impossible to remove a notification listener on client
side from a already unregistered mbean and add the listener again after the
same mbean is registered again.

The ClientInvoker class implements the MBeanServerConnection and is
responsible to invoke operations on the remote mbean server vi a RMI.

In the add and removeNotificationListener methods the list of notification
listeners is updated whenever a listener is added or removed. This works
fine as long as no exceptions are thrown by the remote mbean server, eg.
InstanceNotFound (eg. when the mbean was unregistered) or ListenerNotFound
(eg. when the mbean was unregistered and registered again). In this case the
exception is forwarded to the caller but the list is not updated.


public void removeNotificationListener(ObjectName observed,
NotificationListener listener)
           throws InstanceNotFoundException, ListenerNotFoundException,
IOException
   {
      Integer[] ids = notificationHandler.getNotificationListeners(new
NotificationTuple(observed, listener));
      if (ids == null) throw new ListenerNotFoundException("Could not find
listener " + listener);
      connection.removeNotificationListeners(observed, ids, delegate);
      notificationHandler.removeNotificationListeners(ids);
   }

When now for the same observer - listener pair a notification listener is
added and the entry is found in the list the notification is not forwarded
to the mbean server

 public void addNotificationListener(ObjectName observed,
NotificationListener listener, NotificationFilter filter, Object handback)
           throws InstanceNotFoundException, IOException
   {
      NotificationTuple tuple = new NotificationTuple(observed, listener,
filter, handback);
      if (notificationHandler.contains(tuple)) return;

      MarshalledObject f = null;
      try
      {
         f = RMIMarshaller.marshal(filter);
      }
      catch (NotSerializableException x)
      {
         // Invoke the filter on client side
         tuple.setInvokeFilter(true);
      }
      Integer[] ids = connection.addNotificationListeners(new
ObjectName[]{observed}, new MarshalledObject[]{f}, new Subject[]{delegate});
      notificationHandler.addNotificationListener(ids[0], tuple);
   }

In my opinon the removeNotificationHandler methods have to update the list
in case of InstanceNotFound and ListenerNotFound Exceptions because this
listeners are not valid any longer.

public void removeNotificationListener(ObjectName observed,
NotificationListener listener)
           throws InstanceNotFoundException, ListenerNotFoundException,
IOException
   {
      Integer[] ids = notificationHandler.getNotificationListeners(new
NotificationTuple(observed, listener));
      if (ids == null) throw new ListenerNotFoundException("Could not find
listener " + listener);
	try
	{
      	connection.removeNotificationListeners(observed, ids, delegate);
      	notificationHandler.removeNotificationListeners(ids);
	}
	catch (InstanceNotFoundException e)
	{
		notificationHandler.removeNotificationListeners(ids);
		throw e;
	}
	catch (ListenerNotFoundException e)
	{
		notificationHandler.removeNotificationListeners(ids);
		throw e;
	}
	catch (IOException e)
	{
		throw e;
	}
   }


Mit freundlichen Grüßen
Jens Rottgardt
FIS e-volution
GOB-2

Postadresse:
Volkswagen AG
Brieffach 1839/0
38436 Wolfsburg

Besucheradresse:

Alessandro-Volta Straße 11
38440 Wolfsburg

Telefon +49 (0) 5361-186 736
Telefax +49 (0) 5361-186 798

mailto:[email protected] <mailto:[email protected]> 
http://www.volkswagen.de <http://www.volkswagen.de>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.