Program: 46982
Project: 46982
Buggy source:
@Override public String getReverseRoute(Class<?> controllerClass,String controllerMethodName,Map<String,Object> parameterMap){
  if (routes == null) {
    throw new IllegalStateException("String_Node_Str");
  }
  for (  Route route : routes) {
    if (route.getControllerClass() != null && route.getControllerClass().equals(controllerClass) && route.getControllerMethod().getName().equals(controllerMethodName)) {
      String urlWithReplacedPlaceholders=route.getUrl();
      Map<String,Object> queryParameterMap=Maps.newHashMap();
      for (      Entry<String,Object> parameterPair : parameterMap.entrySet()) {
        String originalRegex=String.format("String_Node_Str",parameterPair.getKey());
        String originalRegexEscaped=String.format("String_Node_Str",parameterPair.getKey());
        String resultingRegexReplacement=parameterPair.getValue().toString();
        if (urlWithReplacedPlaceholders.contains(originalRegex)) {
          urlWithReplacedPlaceholders=urlWithReplacedPlaceholders.replaceAll(originalRegexEscaped,resultingRegexReplacement);
        }
 else {
          queryParameterMap.put(parameterPair.getKey(),parameterPair.getValue());
        }
      }
      if (queryParameterMap.entrySet().size() > 0) {
        StringBuffer queryParameterStringBuffer=new StringBuffer();
        for (Iterator<Entry<String,Object>> iterator=queryParameterMap.entrySet().iterator(); iterator.hasNext(); ) {
          Entry<String,Object> queryParameterEntry=iterator.next();
          queryParameterStringBuffer.append(queryParameterEntry.getKey());
          queryParameterStringBuffer.append("String_Node_Str");
          queryParameterStringBuffer.append(queryParameterEntry.getValue());
          if (iterator.hasNext()) {
            queryParameterStringBuffer.append("String_Node_Str");
          }
        }
        urlWithReplacedPlaceholders=urlWithReplacedPlaceholders + "String_Node_Str" + queryParameterStringBuffer.toString();
      }
      String contextPath=ninjaProperties.getContextPath().orNull();
      if (contextPath != null) {
        return contextPath + urlWithReplacedPlaceholders;
      }
      return urlWithReplacedPlaceholders;
    }
  }
  return null;
}

Fixed version (ground truth):
@Override public String getReverseRoute(Class<?> controllerClass,String controllerMethodName,Map<String,Object> parameterMap){
  if (routes == null) {
    throw new IllegalStateException("String_Node_Str");
  }
  for (  Route route : routes) {
    if (route.getControllerClass() != null && route.getControllerClass().equals(controllerClass) && route.getControllerMethod().getName().equals(controllerMethodName)) {
      String urlWithReplacedPlaceholders=route.getUrl();
      Map<String,Object> queryParameterMap=Maps.newHashMap();
      for (      Entry<String,Object> parameterPair : parameterMap.entrySet()) {
        boolean foundAsPathParameter=false;
        StringBuffer stringBuffer=new StringBuffer();
        String buffer=String.format(VARIABLE_PART_PATTERN_WITH_PLACEHOLDER,parameterPair.getKey());
        Pattern PATTERN=Pattern.compile(buffer);
        Matcher matcher=PATTERN.matcher(urlWithReplacedPlaceholders);
        while (matcher.find()) {
          String resultingRegexReplacement=parameterPair.getValue().toString();
          matcher.appendReplacement(stringBuffer,resultingRegexReplacement);
          foundAsPathParameter=true;
        }
        matcher.appendTail(stringBuffer);
        urlWithReplacedPlaceholders=stringBuffer.toString();
        if (!foundAsPathParameter) {
          queryParameterMap.put(parameterPair.getKey(),parameterPair.getValue());
        }
      }
      if (queryParameterMap.entrySet().size() > 0) {
        StringBuffer queryParameterStringBuffer=new StringBuffer();
        for (Iterator<Entry<String,Object>> iterator=queryParameterMap.entrySet().iterator(); iterator.hasNext(); ) {
          Entry<String,Object> queryParameterEntry=iterator.next();
          queryParameterStringBuffer.append(queryParameterEntry.getKey());
          queryParameterStringBuffer.append("String_Node_Str");
          queryParameterStringBuffer.append(queryParameterEntry.getValue());
          if (iterator.hasNext()) {
            queryParameterStringBuffer.append("String_Node_Str");
          }
        }
        urlWithReplacedPlaceholders=urlWithReplacedPlaceholders + "String_Node_Str" + queryParameterStringBuffer.toString();
      }
      if (ninjaProperties.getContextPath().isPresent()) {
        if (!ninjaProperties.getContextPath().get().equals("String_Node_Str")) {
          return ninjaProperties.getContextPath().get() + urlWithReplacedPlaceholders;
        }
      }
      return urlWithReplacedPlaceholders;
    }
  }
  return null;
}