Buggy code:
public class CommandLineMain { private static final Map < String , CommandHandler > handlers = new HashMap < String , CommandHandler > ( ) ; private static void registerHandler ( CommandHandler handler , String ... names ) { } private static final CommandHandler operationHandler = new OperationRequestHandler ( ) ; public static void main ( String [ ] args ) throws Exception { final ConsoleReader console = CommandLineMain . initConsoleReader ( ) ; final CommandLineMain . CommandContextImpl cmdCtx = new CommandLineMain . CommandContextImpl ( console ) ; SecurityActions . addShutdownHook ( new Thread ( new Runnable ( ) { @ Override public void run ( ) { cmdCtx . disconnectController ( ) ; } } ) ) ; OperationRequestCompleter opCompleter = new OperationRequestCompleter ( cmdCtx ) ; <START_BUG> console . addCompletor ( new CommandCompleter ( CommandLineMain . handlers . keySet ( ) , opCompleter ) ) ; <END_BUG> console . addCompletor ( opCompleter ) ; boolean connect = false ; for ( String arg : args ) { if ( arg . startsWith ( "controller=" ) ) { String value = arg . substring ( 11 ) ; String portStr = null ; int colonIndex = value . indexOf ( ':' ) ; if ( colonIndex < 0 ) { cmdCtx . defaultControllerHost = value ; } else if ( colonIndex == 0 ) { portStr = value . substring ( 1 ) ; } else { cmdCtx . defaultControllerHost = value . substring ( 0 , colonIndex ) ; portStr = value . substring ( ( colonIndex + 1 ) ) ; } if ( portStr != null ) { int port = - 1 ; try { port = Integer . parseInt ( portStr ) ; if ( port < 0 ) { cmdCtx . printLine ( ( ( "The<seq2seq4repair_space>port<seq2seq4repair_space>must<seq2seq4repair_space>be<seq2seq4repair_space>a<seq2seq4repair_space>valid<seq2seq4repair_space>non-negative<seq2seq4repair_space>integer:<seq2seq4repair_space>'" + args ) + "'" ) ) ; } else { cmdCtx . defaultControllerPort = port ; } } catch ( NumberFormatException e ) { cmdCtx . printLine ( ( ( "The<seq2seq4repair_space>port<seq2seq4repair_space>must<seq2seq4repair_space>be<seq2seq4repair_space>a<seq2seq4repair_space>valid<seq2seq4repair_space>non-negative<seq2seq4repair_space>integer:<seq2seq4repair_space>'" + arg ) + "'" ) ) ; } } } else if ( "--connect" . equals ( arg ) ) { connect = true ; } } if ( connect ) { cmdCtx . connectController ( null , ( - 1 ) ) ; } else { cmdCtx . printLine ( ( "You<seq2seq4repair_space>are<seq2seq4repair_space>disconnected<seq2seq4repair_space>at<seq2seq4repair_space>the<seq2seq4repair_space>moment." + ( "<seq2seq4repair_space>Type<seq2seq4repair_space>'connect'<seq2seq4repair_space>to<seq2seq4repair_space>connect<seq2seq4repair_space>to<seq2seq4repair_space>the<seq2seq4repair_space>server<seq2seq4repair_space>or" + "<seq2seq4repair_space>'help'<seq2seq4repair_space>for<seq2seq4repair_space>the<seq2seq4repair_space>list<seq2seq4repair_space>of<seq2seq4repair_space>supported<seq2seq4repair_space>commands." ) ) ) ; } while ( ! ( cmdCtx . terminate ) ) { String line = console . readLine ( cmdCtx . getPrompt ( ) ) . trim ( ) ; if ( line . isEmpty ( ) ) { continue ; } if ( CommandLineMain . isOperation ( line ) ) { cmdCtx . cmdArgs = line ; CommandLineMain . operationHandler . handle ( cmdCtx ) ; } else { String cmd = line ; cmdCtx . cmdArgs = null ; for ( int i = 0 ; i < ( cmd . length ( ) ) ; ++ i ) { if ( Character . isWhitespace ( cmd . charAt ( i ) ) ) { cmdCtx . cmdArgs = cmd . substring ( ( i + 1 ) ) . trim ( ) ; cmd = cmd . substring ( 0 , i ) ; break ; } } CommandHandler handler = CommandLineMain . handlers . get ( cmd . toLowerCase ( ) ) ; if ( handler != null ) { handler . handle ( cmdCtx ) ; } else { cmdCtx . printLine ( ( ( "Unexpected<seq2seq4repair_space>command<seq2seq4repair_space>'" + line ) + "'.<seq2seq4repair_space>Type<seq2seq4repair_space>'help'<seq2seq4repair_space>for<seq2seq4repair_space>the<seq2seq4repair_space>list<seq2seq4repair_space>of<seq2seq4repair_space>supported<seq2seq4repair_space>commands." ) ) ; } } } StreamUtils . safeClose ( cmdCtx . client ) ; } protected static ConsoleReader initConsoleReader ( ) { } private static boolean isOperation ( String line ) { } private static class CommandContextImpl implements CommandContext { private final ConsoleReader console ; private final CommandHistory history ; private boolean terminate ; private String cmdArgs ; private ModelControllerClient client ; private String defaultControllerHost = "localhost" ; private int defaultControllerPort = 9999 ; private String controllerHost ; private int controllerPort = - 1 ; private Map < String , Object > map = new HashMap < String , Object > ( ) ; private final OperationRequestParser parser = new DefaultOperationRequestParser ( ) ; private final OperationRequestAddress prefix = new DefaultOperationRequestAddress ( ) ; private final PrefixFormatter prefixFormatter = new DefaultPrefixFormatter ( ) ; private final OperationCandidatesProvider operationCandidatesProvider ; private CommandContextImpl ( ConsoleReader console ) { } @ Override public String getCommandArguments ( ) { } @ Override public void terminateSession ( ) { } @ Override public void printLine ( String message ) { } @ Override public void printColumns ( Collection < String > col ) { } @ Override public void set ( String key , Object value ) { } @ Override public Object get ( String key ) { } @ Override public ModelControllerClient getModelControllerClient ( ) { } @ Override public OperationRequestParser getOperationRequestParser ( ) { } @ Override public OperationRequestAddress getPrefix ( ) { } @ Override public PrefixFormatter getPrefixFormatter ( ) { } @ Override public OperationCandidatesProvider getOperationCandidatesProvider ( ) { } @ Override public void connectController ( String host , int port ) { } @ Override public void disconnectController ( ) { } @ Override public String getControllerHost ( ) { } @ Override public int getControllerPort ( ) { } String getPrompt ( ) { } @ Override public CommandHistory getHistory ( ) { } private class HistoryImpl implements CommandHistory { @ SuppressWarnings ( "unchecked" ) @ Override public List < String > asList ( ) { } @ Override public boolean isUseHistory ( ) { } @ Override public void setUseHistory ( boolean useHistory ) { } @ Override public void clear ( ) { } } @ Override public String getDefaultControllerHost ( ) { } @ Override public int getDefaultControllerPort ( ) { } } }

Fix:
console . addCompletor ( new CommandCompleter ( CommandLineMain . handlers . keySet ( ) , cmdCtx , opCompleter ) ) ;