Program: 68933
Project: 68933
Buggy source:
public static RequestPrepareResult prepareRequest(String url,Map<String,String> parameters,boolean addRegularQueryStringParameters) throws UnsupportedEncodingException {
  if (parameters == null) {
    parameters=new HashMap<String,String>();
  }
  Set<String> keySet=new HashSet<String>(parameters.keySet());
  for (  String key : keySet) {
    if (parameters.get(key) == null) {
      parameters.remove(key);
    }
  }
  Pattern p=Pattern.compile("String_Node_Str");
  Matcher matcher=p.matcher(url);
  String finalUrl=url;
  while (matcher.find()) {
    String key=matcher.group(1);
    if (parameters.containsKey(key)) {
      String parameterValue=parameters.get(key);
      finalUrl=finalUrl.replaceAll("String_Node_Str" + key + "String_Node_Str","String_Node_Str" + URLEncoder.encode(parameterValue,"String_Node_Str"));
      finalUrl=finalUrl.replaceAll("String_Node_Str" + key + "String_Node_Str",UriUtils.encodeUri(parameterValue,"String_Node_Str"));
    }
 else {
      finalUrl=finalUrl.replaceAll("String_Node_Str" + key + "String_Node_Str","String_Node_Str");
    }
  }
  finalUrl=finalUrl.replaceAll("String_Node_Str","String_Node_Str");
  finalUrl=finalUrl.replaceAll("String_Node_Str","String_Node_Str");
  if (addRegularQueryStringParameters) {
    addRegularQueryStringParameters(finalUrl,parameters);
  }
 else {
    for (    String key : parameters.keySet()) {
      String delimiter=(finalUrl.indexOf("String_Node_Str") > 0) ? "String_Node_Str" : "String_Node_Str";
      finalUrl+=delimiter + key + "String_Node_Str"+ parameters.get(key);
    }
  }
  return new RequestPrepareResult(finalUrl,parameters);
}

Fixed version (ground truth):
public static RequestPrepareResult prepareRequest(String url,Map<String,String> parameters,boolean addRegularQueryStringParameters) throws UnsupportedEncodingException {
  if (parameters == null) {
    parameters=new HashMap<String,String>();
  }
  Set<String> keySet=new HashSet<String>(parameters.keySet());
  for (  String key : keySet) {
    if (parameters.get(key) == null) {
      parameters.remove(key);
    }
  }
  Pattern p=Pattern.compile("String_Node_Str");
  Matcher matcher=p.matcher(url);
  String finalUrl=url;
  while (matcher.find()) {
    String key=matcher.group(1);
    if (parameters.containsKey(key)) {
      String parameterValue=parameters.get(key);
      finalUrl=finalUrl.replaceAll("String_Node_Str" + key + "String_Node_Str","String_Node_Str" + URLEncoder.encode(parameterValue,"String_Node_Str"));
      finalUrl=finalUrl.replaceAll("String_Node_Str" + key + "String_Node_Str",UriUtils.encodeUri(parameterValue,"String_Node_Str"));
      parameters.remove(key);
    }
 else {
      finalUrl=finalUrl.replaceAll("String_Node_Str" + key + "String_Node_Str","String_Node_Str");
    }
  }
  finalUrl=finalUrl.replaceAll("String_Node_Str","String_Node_Str");
  finalUrl=finalUrl.replaceAll("String_Node_Str","String_Node_Str");
  if (addRegularQueryStringParameters) {
    addRegularQueryStringParameters(finalUrl,parameters);
  }
 else {
    for (    String key : parameters.keySet()) {
      String delimiter=(finalUrl.indexOf("String_Node_Str") > 0) ? "String_Node_Str" : "String_Node_Str";
      finalUrl+=delimiter + key + "String_Node_Str"+ parameters.get(key);
    }
  }
  return new RequestPrepareResult(finalUrl,parameters);
}