Program: 10881
Project: 10881
Buggy source:
public static void setOptionVariableValues(ServiceCommand serviceCommand,Map<String,String> variableToValueMap){
  CommandOptions commandOptions=serviceCommand.getOptions();
  if (commandOptions == null || commandOptions.getOptions() == null) {
    return;
  }
  String options=commandOptions.getOptions();
  StringBuffer variableBuffer=null;
  StringBuffer resolvedOptions=new StringBuffer(options);
  int dollarSignIndex=-1;
  for (int i=0; i < resolvedOptions.length(); i++) {
    if (resolvedOptions.charAt(i) == '$') {
      dollarSignIndex=i;
      variableBuffer=new StringBuffer();
    }
 else     if ((Character.isSpaceChar(resolvedOptions.charAt(i)) || i == resolvedOptions.length() - 1) && variableBuffer != null) {
      if (!Character.isSpaceChar(resolvedOptions.charAt(i))) {
        variableBuffer.append(resolvedOptions.charAt(i));
      }
      if (variableBuffer.length() > 0) {
        String variable=variableBuffer.toString();
        String value=variableToValueMap.get(variable);
        int endingIndex=dollarSignIndex + variable.length();
        if (value != null && dollarSignIndex >= 0 && (endingIndex < resolvedOptions.length())) {
          resolvedOptions.replace(dollarSignIndex,endingIndex,"String_Node_Str");
          resolvedOptions.insert(dollarSignIndex,value);
        }
      }
      variableBuffer=null;
      dollarSignIndex=-1;
    }
 else     if (variableBuffer != null) {
      variableBuffer.append(resolvedOptions.charAt(i));
    }
  }
  CommandOptions resolvedOp=new CommandOptions();
  resolvedOp.setOptions(resolvedOptions.toString());
  serviceCommand.setOptions(resolvedOp);
}

Fixed version (ground truth):
public static void setOptionVariableValues(ServiceCommand serviceCommand,Map<String,String> variableToValueMap){
  CommandOptions commandOptions=serviceCommand.getOptions();
  if (commandOptions == null || commandOptions.getOptions() == null) {
    return;
  }
  String options=commandOptions.getOptions();
  StringBuffer variableBuffer=null;
  StringBuffer resolvedOptions=new StringBuffer(options);
  int dollarSignIndex=-1;
  for (int i=0; i < resolvedOptions.length(); i++) {
    if (resolvedOptions.charAt(i) == '$') {
      dollarSignIndex=i;
      variableBuffer=new StringBuffer();
    }
 else     if ((Character.isSpaceChar(resolvedOptions.charAt(i)) || i == resolvedOptions.length() - 1) && variableBuffer != null) {
      if (!Character.isSpaceChar(resolvedOptions.charAt(i))) {
        variableBuffer.append(resolvedOptions.charAt(i));
      }
      if (variableBuffer.length() > 0) {
        String variable=variableBuffer.toString();
        String value=variableToValueMap.get(variable);
        int endingIndex=dollarSignIndex + variable.length() + 1;
        if (value != null && dollarSignIndex >= 0 && (endingIndex < resolvedOptions.length())) {
          resolvedOptions.replace(dollarSignIndex,endingIndex,"String_Node_Str");
          resolvedOptions.insert(dollarSignIndex,value);
        }
      }
      variableBuffer=null;
      dollarSignIndex=-1;
    }
 else     if (variableBuffer != null) {
      variableBuffer.append(resolvedOptions.charAt(i));
    }
  }
  CommandOptions resolvedOp=new CommandOptions();
  resolvedOp.setOptions(resolvedOptions.toString());
  serviceCommand.setOptions(resolvedOp);
}