Program: 28587
Project: 28587
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;
  int rc=0;
  programOpts.toEnvironment(env);
  String prompt=programOpts.getCommandName() + "String_Node_Str";
  for (; ; ) {
    if (printPrompt) {
      System.out.print(prompt);
      System.out.flush();
    }
    if ((line=reader.readLine()) == null) {
      if (printPrompt)       System.out.println();
      break;
    }
    if (line.trim().startsWith("String_Node_Str"))     continue;
    String[] args;
    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());
      po.setCommandName(programOpts.getCommandName());
      atomicReplace(habitat,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(container,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(container),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 {
      atomicReplace(habitat,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(programOpts.getCommandName() + "String_Node_Str",env,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;
  int rc=0;
  programOpts.toEnvironment(env);
  String prompt=programOpts.getCommandName() + "String_Node_Str";
  for (; ; ) {
    if (printPrompt) {
      System.out.print(prompt);
      System.out.flush();
    }
    if ((line=reader.readLine()) == null) {
      if (printPrompt)       System.out.println();
      break;
    }
    if (line.trim().startsWith("String_Node_Str"))     continue;
    String[] args;
    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());
      po.setCommandName(programOpts.getCommandName());
      atomicReplace(habitat,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 {
        if (po != null)         CLIUtil.displayClosestMatch(command,CLIUtil.getAllCommands(container,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(container),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 {
      atomicReplace(habitat,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(programOpts.getCommandName() + "String_Node_Str",env,args,rc);
}
return rc;
}