Program: 126355
Project: 126355
Buggy source:
private static String doReplace(String oldName,String newName,String value){
  String vOldName=oldName.replaceAll("String_Node_Str","String_Node_Str");
  String regex="String_Node_Str" + vOldName + "String_Node_Str"+ vOldName+ "String_Node_Str";
  String[] split=value.split(regex);
  Map<String,String> replacedStrings=new HashMap<String,String>();
  StringBuffer returnValue=new StringBuffer();
  for (  String s : split) {
    if (s.contains(oldName)) {
      replacedStrings.put(s,s.replaceAll("String_Node_Str" + oldName + "String_Node_Str",newName));
    }
 else {
      replacedStrings.put(s,s);
    }
  }
  if (split.length == 1) {
    returnValue.append(replacedStrings.get(split[0]));
  }
  java.util.regex.Pattern pattern=java.util.regex.Pattern.compile(regex);
  Matcher matcher=pattern.matcher(value);
  if (matcher.find()) {
    int x=matcher.start();
    int y=matcher.end();
    int curPos=0;
    int valueLength=value.length();
    String oldFill=null;
    String newFill=null;
    while (true) {
      if (curPos == valueLength) {
        break;
      }
      if (curPos < x) {
        oldFill=value.substring(curPos,x);
        if ((newFill=replacedStrings.get(oldFill)) != null) {
          returnValue.append(newFill);
        }
 else {
          returnValue.append(oldFill);
        }
        curPos=x;
        continue;
      }
      returnValue.append(matcher.group());
      curPos=y;
      if (!matcher.find()) {
        x=valueLength;
      }
 else {
        x=matcher.start();
        y=matcher.end();
      }
    }
  }
  return returnValue.toString();
}

Fixed version (ground truth):
private static String doReplace(String oldName,String newName,String value){
  if (value.trim().isEmpty()) {
    return value;
  }
  String vOldName=oldName.replaceAll("String_Node_Str","String_Node_Str");
  String regex="String_Node_Str" + vOldName + "String_Node_Str"+ vOldName+ "String_Node_Str";
  String[] split=value.split(regex);
  Map<String,String> replacedStrings=new HashMap<String,String>();
  StringBuffer returnValue=new StringBuffer();
  for (  String s : split) {
    if (s.contains(oldName)) {
      replacedStrings.put(s,s.replaceAll("String_Node_Str" + oldName + "String_Node_Str",newName));
    }
 else {
      replacedStrings.put(s,s);
    }
  }
  if (split.length == 1) {
    returnValue.append(replacedStrings.get(split[0]));
  }
  java.util.regex.Pattern pattern=java.util.regex.Pattern.compile(regex);
  Matcher matcher=pattern.matcher(value);
  if (matcher.find()) {
    int x=matcher.start();
    int y=matcher.end();
    int curPos=0;
    int valueLength=value.length();
    String oldFill=null;
    String newFill=null;
    String subRegEx="String_Node_Str" + vOldName + "String_Node_Str";
    java.util.regex.Pattern subPattern=java.util.regex.Pattern.compile(subRegEx);
    while (true) {
      if (curPos == valueLength) {
        break;
      }
      if (curPos < x) {
        oldFill=value.substring(curPos,x);
        if ((newFill=replacedStrings.get(oldFill)) != null) {
          returnValue.append(newFill);
        }
 else {
          returnValue.append(oldFill);
        }
        curPos=x;
        continue;
      }
      String matchedString=matcher.group();
      Matcher subMatcher=subPattern.matcher(matchedString);
      if (subMatcher.find()) {
        returnValue.append(matchedString.replaceFirst(vOldName,newName));
      }
 else {
        returnValue.append(matchedString);
      }
      curPos=y;
      if (!matcher.find()) {
        x=valueLength;
      }
 else {
        x=matcher.start();
        y=matcher.end();
      }
    }
  }
  return returnValue.toString();
}