Program: 81049
Project: 81049
Buggy source:
/** 
 * Parses the command line arguments and set them to the option bean given in the constructor.
 * @param args arguments to parse
 * @throws CmdLineException if there's any error parsing arguments, or if {@link Option#required() required} option was not given.
 */
public void parseArgument(final String... args) throws CmdLineException {
  CmdLineImpl cmdLine=new CmdLineImpl(args);
  Set<OptionHandler> present=new HashSet<OptionHandler>();
  int argIndex=0;
  while (cmdLine.hasMore()) {
    String arg=cmdLine.getCurrentToken();
    if (isOption(arg)) {
      boolean isKeyValuePair=arg.indexOf('=') != -1;
      currentOptionHandler=isKeyValuePair ? findOptionHandler(arg) : findOptionByName(arg);
      if (currentOptionHandler == null) {
        throw new CmdLineException(this,Messages.UNDEFINED_OPTION.format(arg));
      }
      cmdLine.proceed(1);
    }
 else {
      if (argIndex >= arguments.size()) {
        Messages msg=arguments.size() == 0 ? Messages.NO_ARGUMENT_ALLOWED : Messages.TOO_MANY_ARGUMENTS;
        throw new CmdLineException(this,msg.format(arg));
      }
      currentOptionHandler=arguments.get(argIndex);
      if (!currentOptionHandler.option.isMultiValued())       argIndex++;
    }
    int diff=currentOptionHandler.parseArguments(cmdLine);
    cmdLine.proceed(diff);
    present.add(currentOptionHandler);
  }
  for (  OptionHandler handler : options)   if (handler.option.required() && !present.contains(handler))   throw new CmdLineException(this,Messages.REQUIRED_OPTION_MISSING.format(handler.option.toString()));
  for (  OptionHandler handler : arguments)   if (handler.option.required() && !present.contains(handler))   throw new CmdLineException(this,Messages.REQUIRED_ARGUMENT_MISSING.format(handler.option.toString()));
}

Fixed version (ground truth):
/** 
 * Parses the command line arguments and set them to the option bean given in the constructor.
 * @param args arguments to parse
 * @throws CmdLineException if there's any error parsing arguments, or if {@link Option#required() required} option was not given.
 */
public void parseArgument(final String... args) throws CmdLineException {
  CmdLineImpl cmdLine=new CmdLineImpl(args);
  Set<OptionHandler> present=new HashSet<OptionHandler>();
  int argIndex=0;
  while (cmdLine.hasMore()) {
    String arg=cmdLine.getCurrentToken();
    if (isOption(arg)) {
      boolean isKeyValuePair=arg.indexOf('=') != -1;
      currentOptionHandler=isKeyValuePair ? findOptionHandler(arg) : findOptionByName(arg);
      if (currentOptionHandler == null) {
        throw new CmdLineException(this,Messages.UNDEFINED_OPTION.format(arg));
      }
      cmdLine.proceed(1);
    }
 else {
      if (argIndex >= arguments.size()) {
        Messages msg=arguments.size() == 0 ? Messages.NO_ARGUMENT_ALLOWED : Messages.TOO_MANY_ARGUMENTS;
        throw new CmdLineException(this,msg.format(arg));
      }
      currentOptionHandler=arguments.get(argIndex);
      if (currentOptionHandler == null)       throw new IllegalStateException("String_Node_Str" + argIndex + "String_Node_Str");
      if (!currentOptionHandler.option.isMultiValued())       argIndex++;
    }
    int diff=currentOptionHandler.parseArguments(cmdLine);
    cmdLine.proceed(diff);
    present.add(currentOptionHandler);
  }
  for (  OptionHandler handler : options)   if (handler.option.required() && !present.contains(handler))   throw new CmdLineException(this,Messages.REQUIRED_OPTION_MISSING.format(handler.option.toString()));
  for (  OptionHandler handler : arguments)   if (handler.option.required() && !present.contains(handler))   throw new CmdLineException(this,Messages.REQUIRED_ARGUMENT_MISSING.format(handler.option.toString()));
}