1 Reply Latest reply on Apr 4, 2006 11:51 AM by Tom Elrod

    (Very) Small MulticastDetector Bug

    Christian Platta Newbie

      Hi,
      I think I found a (very) small bug in the MulticastDetector implementation.
      If you don't call start and then stop or if you call stop twice, you will get a NullPointerException (see JUnit test below). This is no major issue (after all you can just call the methods correctly), but I think frameworks shouldn't produce NullPointerExceptions when used incorrectly.

      public class MulticastDetectorTest extends TestCase {
      
       private MBeanServer server;
      
       private ObjectName objectName;
      
       protected void setUp() throws Exception {
       super.setUp();
       server = ManagementFactory.getPlatformMBeanServer();
       objectName = new ObjectName("remoting:type=MulticastDetector");
       }
      
       protected void tearDown() throws Exception {
       super.tearDown();
       }
      
       public void testStopWithoutStart() throws Exception {
       MulticastDetector detector = new MulticastDetector();
       server.registerMBean(detector, objectName);
       // don't call detector.start();
       Thread.sleep(1000);
      
       server.unregisterMBean(objectName);
       detector.stop();
       }
      
       public void testCallingStopTwice() throws Exception {
       MulticastDetector detector = new MulticastDetector();
       server.registerMBean(detector, objectName);
       detector.start();
       Thread.sleep(1000);
      
       server.unregisterMBean(objectName);
       detector.stop();
       detector.stop();
       }
      }
      


      Chris