Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6764454

EventClient.unsubscribe throws LNFE if the MBean we subscribed to is gone

XMLWordPrintable

      As of JDK 7 b38.
      Consider the following sequence, plainName is NOT a pattern:

      EventClient.subscribe(plainName, listener, null, null);
      MBeanServer.unregister(plainName);
      EventClient.unsubscribe(plainName, listener);

      ==> you get a ListenerNotFoundException, see the stack below.

      [1] the javadoc doesn't say ListenerNotFoundException is thrown in such a case. It's a disconnect between implementation and spec.
      Current javadoc says:
      Throws:
          ListenerNotFoundException - The given listener was not subscribed to the given name.

      [2] If in place of a plain name you use a pattern you don't get any exception. The behavior isn't symmetric, this isn't intuitive.

      javax.management.ListenerNotFoundException: The listener is not found.
      at javax.management.event.EventClientDelegate$ClientInfo.removeListenerInfo(EventClientDelegate.java:570)
      at javax.management.event.EventClientDelegate.removeListenerOrSubscriber(EventClientDelegate.java:416)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:623)
      at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:112)
      at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:46)
      at com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:292)
      at com.sun.jmx.mbeanserver.PerInterface.invoke(PerInterface.java:138)
      at com.sun.jmx.mbeanserver.MBeanSupport.invoke(MBeanSupport.java:252)
      at javax.management.StandardMBean.invoke(StandardMBean.java:648)
      at javax.management.namespace.MBeanServerSupport.invoke(MBeanServerSupport.java:702)
      at com.sun.jmx.interceptor.SingleMBeanForwarder.invoke(SingleMBeanForwarder.java:279)
      at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:623)
      at javax.management.ClientContext$ContextInvocationHandler.invoke(ClientContext.java:1023)
      at javax.management.ClientContext$ContextInvocationHandler.invoke(ClientContext.java:969)
      at $Proxy1.invoke(Unknown Source)
      at javax.management.remote.IdentityMBeanServerForwarder.invoke(IdentityMBeanServerForwarder.java:161)
      at com.sun.jmx.interceptor.SingleMBeanForwarder.invoke(SingleMBeanForwarder.java:281)
      at javax.management.remote.IdentityMBeanServerForwarder.invoke(IdentityMBeanServerForwarder.java:161)
      at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1754)
      at javax.management.remote.rmi.RMIConnectionImpl.access$1000(RMIConnectionImpl.java:99)
      at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1599)
      at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1687)
      at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:813)
      at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:623)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322)
      at sun.rmi.transport.Transport$1.run(Transport.java:177)
      at sun.rmi.transport.Transport$1.run(Transport.java:174)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:553)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
      at java.lang.Thread.run(Thread.java:713)

            sjiang Shanliang Jiang (Inactive)
            yjoan Yves Joan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: