Buggy code:
public class TestClient { public static void main ( String [ ] args ) throws Exception { try { System . out . println ( ) ; TestClient . getUserInput ( ( "Testing<seq2seq4repair_space>JMX<seq2seq4repair_space>Connectors\n" + ( ( ( "======================\n\n" + "1.<seq2seq4repair_space>Instantiate<seq2seq4repair_space>local<seq2seq4repair_space>MBeanServer<seq2seq4repair_space>and<seq2seq4repair_space>add<seq2seq4repair_space>connector<seq2seq4repair_space>" ) + "factory<seq2seq4repair_space>as<seq2seq4repair_space>first<seq2seq4repair_space>MBean<seq2seq4repair_space>to<seq2seq4repair_space>search<seq2seq4repair_space>your<seq2seq4repair_space>net\n" ) + "=><seq2seq4repair_space>hit<seq2seq4repair_space>any<seq2seq4repair_space>key<seq2seq4repair_space>to<seq2seq4repair_space>proceed" ) ) ) ; final MBeanServer lLocalServer = MBeanServerFactory . createMBeanServer ( ) ; final ObjectInstance lFactoryInstance = lLocalServer . createMBean ( "org.jboss.jmx.connector.ConnectorFactoryService" , new ObjectName ( lLocalServer . getDefaultDomain ( ) , "name" , "ConnectorFactory" ) ) ; System . out . println ( ( "Found<seq2seq4repair_space>Factory:<seq2seq4repair_space>" + ( lFactoryInstance . getObjectName ( ) ) ) ) ; int lType = - 1 ; while ( ( lType < 1 ) || ( lType > 3 ) ) { lType = TestClient . getUserInput ( ( "\n" + ( "2.<seq2seq4repair_space>Do<seq2seq4repair_space>you<seq2seq4repair_space>want<seq2seq4repair_space>to<seq2seq4repair_space>use<seq2seq4repair_space>RMI<seq2seq4repair_space>or<seq2seq4repair_space>JMS<seq2seq4repair_space>to<seq2seq4repair_space>transfer<seq2seq4repair_space>Notifications\n" + "=><seq2seq4repair_space>enter<seq2seq4repair_space>1<seq2seq4repair_space>from<seq2seq4repair_space>RMI,<seq2seq4repair_space>2<seq2seq4repair_space>for<seq2seq4repair_space>JMS<seq2seq4repair_space>or<seq2seq4repair_space>3<seq2seq4repair_space>for<seq2seq4repair_space>Polling<seq2seq4repair_space>and<seq2seq4repair_space>then<seq2seq4repair_space>hit<seq2seq4repair_space>enter" ) ) ) ; System . out . println ( ( "Type:<seq2seq4repair_space>" + lType ) ) ; } switch ( lType ) { case 1 : lType = RemoteMBeanServer . NOTIFICATION_TYPE_RMI ; break ; case 2 : lType = RemoteMBeanServer . NOTIFICATION_TYPE_JMS ; break ; case 3 : lType = RemoteMBeanServer . NOTIFICATION_TYPE_POLLING ; } lLocalServer . setAttribute ( lFactoryInstance . getObjectName ( ) , new Attribute ( "NotificationType" , new Integer ( lType ) ) ) ; String lJMSName = null ; if ( lType == ( RemoteMBeanServer . NOTIFICATION_TYPE_JMS ) ) { while ( ( lJMSName == null ) || ( ( lJMSName . trim ( ) . length ( ) ) == 0 ) ) { lJMSName = TestClient . getUserInputLine ( ( "\n" + "2.a.<seq2seq4repair_space>Enter<seq2seq4repair_space>the<seq2seq4repair_space>JMS<seq2seq4repair_space>Queue<seq2seq4repair_space>Factory<seq2seq4repair_space>Name<seq2seq4repair_space>and<seq2seq4repair_space>hit<seq2seq4repair_space>enter\n" ) ) ; } } if ( ( lJMSName == null ) || ( ( lJMSName . trim ( ) . length ( ) ) == 0 ) ) { lJMSName = null ; } lLocalServer . setAttribute ( lFactoryInstance . getObjectName ( ) , new Attribute ( "JMSName" , lJMSName ) ) ; String lEJBAdaptorName = TestClient . getUserInputLine ( ( "\n" + ( ( "3.<seq2seq4repair_space>When<seq2seq4repair_space>you<seq2seq4repair_space>are<seq2seq4repair_space>expecting<seq2seq4repair_space>EJB-Connectors<seq2seq4repair_space>and<seq2seq4repair_space>the<seq2seq4repair_space>EJB-Adaptor\n" + "<seq2seq4repair_space>and<seq2seq4repair_space>the<seq2seq4repair_space>EJB-Adaptor<seq2seq4repair_space>does<seq2seq4repair_space>not<seq2seq4repair_space>have<seq2seq4repair_space>the<seq2seq4repair_space>default<seq2seq4repair_space>JNDI-Name<seq2seq4repair_space>then\n" ) + "<seq2seq4repair_space>then<seq2seq4repair_space>specified<seq2seq4repair_space>it<seq2seq4repair_space>here<seq2seq4repair_space>and<seq2seq4repair_space>hit<seq2seq4repair_space>enter\n" ) ) ) ; if ( ( lEJBAdaptorName == null ) || ( ( lEJBAdaptorName . trim ( ) . length ( ) ) == 0 ) ) { lEJBAdaptorName = null ; } lLocalServer . setAttribute ( lFactoryInstance . getObjectName ( ) , new Attribute ( "EJBAdaptorName" , lEJBAdaptorName ) ) ; <START_BUG> lLocalServer . invoke ( lFactoryInstance . getObjectName ( ) , "init" , new Object [ ] { } , new String [ ] { } ) ; <END_BUG> lLocalServer . invoke ( lFactoryInstance . getObjectName ( ) , "start" , new Object [ ] { } , new String [ ] { } ) ; TestClient . getUserInput ( ( "\n" + ( "4.<seq2seq4repair_space>Lookup<seq2seq4repair_space>for<seq2seq4repair_space>all<seq2seq4repair_space>available<seq2seq4repair_space>connectors<seq2seq4repair_space>with<seq2seq4repair_space>the<seq2seq4repair_space>JNDI<seq2seq4repair_space>defined<seq2seq4repair_space>by<seq2seq4repair_space>jndi.properties\n" + "=><seq2seq4repair_space>hit<seq2seq4repair_space>any<seq2seq4repair_space>key<seq2seq4repair_space>to<seq2seq4repair_space>proceed" ) ) ) ; InitialContext lContext = null ; try { lContext = new InitialContext ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } Hashtable lProperties = lContext . getEnvironment ( ) ; ConnectorFactoryImpl . JBossConnectorTester lTester = new ConnectorFactoryImpl . JBossConnectorTester ( ) ; Iterator lConnectors = ( ( Iterator ) ( lLocalServer . invoke ( lFactoryInstance . getObjectName ( ) , "getConnectors" , new Object [ ] { lProperties , lTester } , new String [ ] { Hashtable . class . getName ( ) , IConnectorTester . class . getName ( ) } ) ) ) ; int lCount = 0 ; StringBuffer lMessage = new StringBuffer ( ) ; lMessage . append ( "List<seq2seq4repair_space>of<seq2seq4repair_space>all<seq2seq4repair_space>available<seq2seq4repair_space>connectors<seq2seq4repair_space>on<seq2seq4repair_space>your<seq2seq4repair_space>net\n" ) ; lMessage . append ( "=========================================\n" ) ; Vector lTemp = new Vector ( ) ; while ( lConnectors . hasNext ( ) ) { ConnectorFactoryImpl . ConnectorName lName = ( ( ConnectorFactoryImpl . ConnectorName ) ( lConnectors . next ( ) ) ) ; lTemp . addElement ( lName ) ; lMessage . append ( ( ( ( ( "<seq2seq4repair_space>-<seq2seq4repair_space>" + ( lCount ++ ) ) + ".<seq2seq4repair_space>connector<seq2seq4repair_space>is:<seq2seq4repair_space>" ) + lName ) + "\n" ) ) ; } int lChoice = - 1 ; while ( ( lChoice < 0 ) || ( lChoice > ( lTemp . size ( ) ) ) ) { lMessage . append ( "\n" ) ; lMessage . append ( "5.<seq2seq4repair_space>Select<seq2seq4repair_space>your<seq2seq4repair_space>connector<seq2seq4repair_space>by<seq2seq4repair_space>entering<seq2seq4repair_space>its<seq2seq4repair_space>number\n" ) ; lMessage . append ( "=><seq2seq4repair_space>hit<seq2seq4repair_space>any<seq2seq4repair_space>key<seq2seq4repair_space>to<seq2seq4repair_space>proceed" ) ; lChoice = TestClient . getUserInput ( lMessage . toString ( ) ) ; } final ConnectorFactoryImpl . ConnectorName lConnectorName = ( ( ConnectorFactoryImpl . ConnectorName ) ( lTemp . get ( lChoice ) ) ) ; lMessage . setLength ( 0 ) ; lMessage . append ( ( ( ( "\n" + "You<seq2seq4repair_space>selected<seq2seq4repair_space>connector:<seq2seq4repair_space>" ) + lConnectorName ) + "\n\n" ) ) ; TestClient . getUserInput ( ( ( ( ( lMessage . toString ( ) ) + "\n" ) + "6.<seq2seq4repair_space>Connect<seq2seq4repair_space>to<seq2seq4repair_space>the<seq2seq4repair_space>given<seq2seq4repair_space>connector\n" ) + "=><seq2seq4repair_space>hit<seq2seq4repair_space>any<seq2seq4repair_space>key<seq2seq4repair_space>to<seq2seq4repair_space>proceed" ) ) ; lMessage . setLength ( 0 ) ; RemoteMBeanServer lConnector = ( ( RemoteMBeanServer ) ( lLocalServer . invoke ( lFactoryInstance . getObjectName ( ) , "createConnection" , new Object [ ] { lConnectorName } , new String [ ] { lConnectorName . getClass ( ) . getName ( ) } ) ) ) ; TestClient . getUserInput ( ( "\n" + ( "7.<seq2seq4repair_space>List<seq2seq4repair_space>all<seq2seq4repair_space>available<seq2seq4repair_space>MBeans<seq2seq4repair_space>and<seq2seq4repair_space>its<seq2seq4repair_space>attributes\n" + "=><seq2seq4repair_space>hit<seq2seq4repair_space>any<seq2seq4repair_space>key<seq2seq4repair_space>to<seq2seq4repair_space>proceed" ) ) ) ; TestClient . listServices ( lConnector ) ; TestClient . getUserInput ( ( "\n" + ( ( ( ( ( "8.<seq2seq4repair_space>Try<seq2seq4repair_space>to<seq2seq4repair_space>add<seq2seq4repair_space>a<seq2seq4repair_space>listener<seq2seq4repair_space>to<seq2seq4repair_space>all<seq2seq4repair_space>available<seq2seq4repair_space>MBeans.\n" + "Please<seq2seq4repair_space>note<seq2seq4repair_space>that<seq2seq4repair_space>this<seq2seq4repair_space>will<seq2seq4repair_space>keep<seq2seq4repair_space>this<seq2seq4repair_space>test<seq2seq4repair_space>client<seq2seq4repair_space>up<seq2seq4repair_space>and<seq2seq4repair_space>running<seq2seq4repair_space>waiting\n" ) + "for<seq2seq4repair_space>an<seq2seq4repair_space>event<seq2seq4repair_space>from<seq2seq4repair_space>the<seq2seq4repair_space>server.<seq2seq4repair_space>If<seq2seq4repair_space>there<seq2seq4repair_space>is<seq2seq4repair_space>no<seq2seq4repair_space>event<seq2seq4repair_space>comming<seq2seq4repair_space>then<seq2seq4repair_space>try\n" ) + "to<seq2seq4repair_space>shutdown<seq2seq4repair_space>the<seq2seq4repair_space>JBoss<seq2seq4repair_space>server.\n" ) + "To<seq2seq4repair_space>end<seq2seq4repair_space>this<seq2seq4repair_space>test<seq2seq4repair_space>client<seq2seq4repair_space>just<seq2seq4repair_space>hit<seq2seq4repair_space><CTRL>-C\n" ) + "=><seq2seq4repair_space>hit<seq2seq4repair_space>any<seq2seq4repair_space>key<seq2seq4repair_space>to<seq2seq4repair_space>proceed" ) ) ) ; TestClient . registerListeners ( lConnector ) ; try { Runtime . getRuntime ( ) . addShutdownHook ( new Thread ( ) { public void run ( ) { System . err . println ( "Shutdown" ) ; try { lLocalServer . invoke ( lFactoryInstance . getObjectName ( ) , "removeConnection" , new Object [ ] { lConnectorName } , new String [ ] { lConnectorName . getClass ( ) . getName ( ) } ) ; System . err . println ( "Shutting<seq2seq4repair_space>done" ) ; }

Fix:
lLocalServer . invoke ( lFactoryInstance . getObjectName ( ) , "create" , new Object [ ] { } , new String [ ] { } ) ;