Program: 29931
Project: 29931
Buggy source:
/** 
 * Read commands from the specified BufferedReader and execute them.  If printPrompt is set, prompt first.
 * @return the exit code of the last command executed
 */
private int executeCommands(BufferedReader reader) throws CommandException, CommandValidationException, IOException {
  String line=null;
  int rc=0;
  programOpts.toEnvironment(env);
  for (; ; ) {
    if (printPrompt) {
      System.out.print("String_Node_Str");
      System.out.flush();
    }
    if ((line=reader.readLine()) == null) {
      if (printPrompt)       System.out.println();
      break;
    }
    if (line.trim().startsWith("String_Node_Str"))     continue;
    String[] args=null;
    try {
      args=getArgs(line);
    }
 catch (    ArgumentTokenizer.ArgumentException ex) {
      logger.info(ex.getMessage());
      continue;
    }
    if (args.length == 0)     continue;
    String command=args[0];
    if (command.length() == 0)     continue;
    if (command.equals("String_Node_Str") || command.equals("String_Node_Str"))     break;
    CLICommand cmd=null;
    ProgramOptions po=null;
    try {
      po=new ProgramOptions(env);
      po.setClassPath(programOpts.getClassPath());
      po.setClassName(programOpts.getClassName());
      habitat.remove(habitat.getInhabitantByType(ProgramOptions.class));
      habitat.addComponent(po);
      cmd=CLICommand.getCommand(habitat,command);
      rc=cmd.execute(args);
    }
 catch (    CommandValidationException cve) {
      logger.severe(cve.getMessage());
      logger.severe(cmd.getUsage());
      rc=ERROR;
    }
catch (    InvalidCommandException ice) {
      logger.severe(ice.getMessage());
      try {
        CLIUtil.displayClosestMatch(command,CLIUtil.getAllCommands(habitat,po,env),strings.get("String_Node_Str"),logger);
      }
 catch (      InvalidCommandException e) {
      }
    }
catch (    CommandException ce) {
      if (ce.getCause() instanceof java.net.ConnectException) {
        logger.severe(ce.getMessage());
        try {
          CLIUtil.displayClosestMatch(command,CLIUtil.getLocalCommands(habitat),strings.get("String_Node_Str"),logger);
        }
 catch (        InvalidCommandException e) {
          logger.info(strings.get("String_Node_Str",command));
        }
      }
 else       logger.severe(ce.getMessage());
      rc=ERROR;
    }
 finally {
      habitat.remove(habitat.getInhabitantByType(ProgramOptions.class));
      habitat.addComponent(programOpts);
    }
switch (rc) {
case SUCCESS:
      if (!programOpts.isTerse())       logger.fine(strings.get("String_Node_Str",command));
    break;
case ERROR:
case INVALID_COMMAND_ERROR:
case CONNECTION_ERROR:
default :
  logger.fine(strings.get("String_Node_Str",command));
break;
}
CLIUtil.writeCommandToDebugLog(args,rc);
}
return rc;
}

Fixed version (ground truth):
/** 
 * Read commands from the specified BufferedReader and execute them.  If printPrompt is set, prompt first.
 * @return the exit code of the last command executed
 */
private int executeCommands(BufferedReader reader) throws CommandException, CommandValidationException, IOException {
  String line=null;
  int rc=0;
  programOpts.toEnvironment(env);
  for (; ; ) {
    if (printPrompt) {
      System.out.print("String_Node_Str");
      System.out.flush();
    }
    if ((line=reader.readLine()) == null) {
      if (printPrompt)       System.out.println();
      break;
    }
    if (line.trim().startsWith("String_Node_Str"))     continue;
    String[] args=null;
    try {
      args=getArgs(line);
    }
 catch (    ArgumentTokenizer.ArgumentException ex) {
      logger.info(ex.getMessage());
      continue;
    }
    if (args.length == 0)     continue;
    String command=args[0];
    if (command.length() == 0)     continue;
    if (command.equals("String_Node_Str") || command.equals("String_Node_Str"))     break;
    CLICommand cmd=null;
    ProgramOptions po=null;
    try {
      po=new ProgramOptions(env);
      po.setClassPath(programOpts.getClassPath());
      po.setClassName(programOpts.getClassName());
      habitat.remove(habitat.getInhabitantByType(ProgramOptions.class));
      habitat.addComponent(po);
      cmd=CLICommand.getCommand(habitat,command);
      rc=cmd.execute(args);
    }
 catch (    CommandValidationException cve) {
      logger.severe(cve.getMessage());
      if (cmd != null)       logger.severe(cmd.getUsage());
      rc=ERROR;
    }
catch (    InvalidCommandException ice) {
      logger.severe(ice.getMessage());
      try {
        CLIUtil.displayClosestMatch(command,CLIUtil.getAllCommands(habitat,po,env),strings.get("String_Node_Str"),logger);
      }
 catch (      InvalidCommandException e) {
      }
    }
catch (    CommandException ce) {
      if (ce.getCause() instanceof java.net.ConnectException) {
        logger.severe(ce.getMessage());
        try {
          CLIUtil.displayClosestMatch(command,CLIUtil.getLocalCommands(habitat),strings.get("String_Node_Str"),logger);
        }
 catch (        InvalidCommandException e) {
          logger.info(strings.get("String_Node_Str",command));
        }
      }
 else       logger.severe(ce.getMessage());
      rc=ERROR;
    }
 finally {
      habitat.remove(habitat.getInhabitantByType(ProgramOptions.class));
      habitat.addComponent(programOpts);
    }
switch (rc) {
case SUCCESS:
      if (!programOpts.isTerse())       logger.fine(strings.get("String_Node_Str",command));
    break;
case ERROR:
case INVALID_COMMAND_ERROR:
case CONNECTION_ERROR:
default :
  logger.fine(strings.get("String_Node_Str",command));
break;
}
CLIUtil.writeCommandToDebugLog(args,rc);
}
return rc;
}