Program: 146164
Project: 146164
Buggy source:
public String getForeignKeyList(int start,int limit,String value,String xpathForeignKey,String xpathInfoForeignKey) throws RemoteException, Exception {
  org.apache.log4j.Logger.getLogger(this.getClass()).debug("String_Node_Str" + xpathForeignKey + "String_Node_Str"+ xpathInfoForeignKey+ "String_Node_Str"+ value+ "String_Node_Str");
  Configuration config=Configuration.getInstance();
  if (xpathForeignKey.split("String_Node_Str").length == 1) {
    String conceptName=xpathForeignKey;
    String[] xpathInfos=new String[0];
    if (!"String_Node_Str".equals(xpathInfoForeignKey))     xpathInfos=xpathInfoForeignKey.split("String_Node_Str");
    String filteredConcept=conceptName;
    if (value != null && !"String_Node_Str".equals(value.trim())) {
      filteredConcept+="String_Node_Str" + value + "String_Node_Str";
    }
    ArrayList<String> xPaths=new ArrayList<String>();
    for (int i=0; i < xpathInfos.length; i++) {
      xPaths.add(xpathInfos[i].replaceFirst(conceptName,filteredConcept));
    }
    xPaths.add(filteredConcept + "String_Node_Str");
    String[] results=Util.getPort().xPathsSearch(new WSXPathsSearch(new WSDataClusterPK(config.getCluster()),filteredConcept,new WSStringArray(xPaths.toArray(new String[xPaths.size()])),null,-1,start,limit,null,null)).getStrings();
    if (results == null)     results=new String[0];
    JSONObject json=new JSONObject();
    json.put("String_Node_Str",results.length);
    JSONArray rows=new JSONArray();
    json.put("String_Node_Str",rows);
    for (int i=0; i < results.length; i++) {
      Element root=Util.parse(results[i]).getDocumentElement();
      NodeList list=root.getChildNodes();
      String keys="String_Node_Str";
      for (int j=xpathInfos.length; j < list.getLength(); j++) {
        Node textNode=list.item(j).getFirstChild();
        keys+="String_Node_Str" + (textNode == null ? "String_Node_Str" : textNode.getNodeValue()) + "String_Node_Str";
      }
      String infos=null;
      if (xpathInfos.length == 0) {
        infos=keys;
      }
 else {
        for (int j=0; j < xpathInfos.length; j++) {
          infos=(infos == null ? "String_Node_Str" : infos + "String_Node_Str");
          Node textNode=list.item(j).getFirstChild();
          infos+=textNode == null ? "String_Node_Str" : textNode.getNodeValue();
        }
      }
      JSONObject row=new JSONObject();
      row.put("String_Node_Str",keys);
      row.put("String_Node_Str",infos);
      rows.put(row);
    }
    return json.toString();
  }
  String[] xpaths=null;
  if (!"String_Node_Str".equals(xpathInfoForeignKey)) {
    String[] xpathInfos=xpathInfoForeignKey.split("String_Node_Str");
    xpaths=new String[xpathInfos.length + 1];
    xpaths[0]=xpathForeignKey;
    System.arraycopy(xpathInfos,0,xpaths,1,xpathInfos.length);
  }
 else {
    xpaths=new String[1];
    xpaths[0]=xpathForeignKey;
  }
  String[] results=Util.getPort().xPathsSearch(new WSXPathsSearch(new WSDataClusterPK(config.getCluster()),xpathForeignKey,new WSStringArray(xpaths),null,-1,0,Integer.MAX_VALUE,null,null)).getStrings();
  if (results == null)   results=new String[0];
  JSONObject json=new JSONObject();
  json.put("String_Node_Str",results.length);
  JSONArray rows=new JSONArray();
  json.put("String_Node_Str",rows);
  for (int i=0; i < results.length; i++) {
    if (results[i] != null) {
      Document d=Util.parse(results[i]);
      String tmp="String_Node_Str";
      for (int j=0; j < xpaths.length; j++) {
        tmp+="String_Node_Str" + Util.getFirstTextNode(d,"String_Node_Str" + xpaths[j].split("String_Node_Str")[xpaths[j].split("String_Node_Str").length - 1]);
      }
      if (Util.getFirstTextNode(d,"String_Node_Str" + xpathForeignKey.split("String_Node_Str")[xpathForeignKey.split("String_Node_Str").length - 1]) != null) {
        String keys=Util.getFirstTextNode(d,"String_Node_Str" + xpathForeignKey.split("String_Node_Str")[xpathForeignKey.split("String_Node_Str").length - 1]);
        String infos=tmp.substring(3);
        JSONObject row=new JSONObject();
        row.put("String_Node_Str",keys);
        row.put("String_Node_Str",infos);
        rows.put(row);
      }
    }
  }
  return json.toString();
}

Fixed version (ground truth):
public String getForeignKeyList(int start,int limit,String value,String xpathForeignKey,String xpathInfoForeignKey) throws RemoteException, Exception {
  org.apache.log4j.Logger.getLogger(this.getClass()).debug("String_Node_Str" + xpathForeignKey + "String_Node_Str"+ xpathInfoForeignKey+ "String_Node_Str"+ value+ "String_Node_Str");
  Configuration config=Configuration.getInstance();
  if (xpathForeignKey.split("String_Node_Str").length == 1) {
    String conceptName=xpathForeignKey;
    String[] xpathInfos=new String[0];
    if (!"String_Node_Str".equals(xpathInfoForeignKey))     xpathInfos=xpathInfoForeignKey.split("String_Node_Str");
    String filteredConcept=conceptName;
    if (value != null && !"String_Node_Str".equals(value.trim())) {
      filteredConcept+="String_Node_Str" + value + "String_Node_Str";
    }
    ArrayList<String> xPaths=new ArrayList<String>();
    for (int i=0; i < xpathInfos.length; i++) {
      xPaths.add(xpathInfos[i].replaceFirst(conceptName,filteredConcept));
    }
    xPaths.add(filteredConcept + "String_Node_Str");
    String[] results=Util.getPort().xPathsSearch(new WSXPathsSearch(new WSDataClusterPK(config.getCluster()),filteredConcept,new WSStringArray(xPaths.toArray(new String[xPaths.size()])),null,-1,start,limit,null,null)).getStrings();
    if (results == null)     results=new String[0];
    JSONObject json=new JSONObject();
    json.put("String_Node_Str",results.length);
    JSONArray rows=new JSONArray();
    json.put("String_Node_Str",rows);
    for (int i=0; i < results.length; i++) {
      Element root=Util.parse(results[i]).getDocumentElement();
      NodeList list=root.getChildNodes();
      String keys="String_Node_Str";
      for (int j=xpathInfos.length; j < list.getLength(); j++) {
        Node textNode=list.item(j).getFirstChild();
        keys+="String_Node_Str" + (textNode == null ? "String_Node_Str" : textNode.getNodeValue()) + "String_Node_Str";
      }
      String infos=null;
      if (xpathInfos.length == 0) {
        infos=keys;
      }
 else {
        for (int j=0; j < xpathInfos.length; j++) {
          infos=(infos == null ? "String_Node_Str" : infos + "String_Node_Str");
          Node textNode=list.item(j).getFirstChild();
          infos+=textNode == null ? "String_Node_Str" : textNode.getNodeValue();
        }
      }
      JSONObject row=new JSONObject();
      row.put("String_Node_Str",keys);
      row.put("String_Node_Str",infos);
      rows.put(row);
    }
    return json.toString();
  }
  String[] xpaths=null;
  if (!"String_Node_Str".equals(xpathInfoForeignKey)) {
    String[] xpathInfos=xpathInfoForeignKey.split("String_Node_Str");
    xpaths=new String[xpathInfos.length + 1];
    xpaths[0]=xpathForeignKey;
    System.arraycopy(xpathInfos,0,xpaths,1,xpathInfos.length);
  }
 else {
    xpaths=new String[1];
    xpaths[0]=xpathForeignKey;
  }
  for (int i=0; i < xpaths.length; i++) {
    String xpath=xpaths[i];
    int pos=xpath.indexOf("String_Node_Str");
    String conceptName=xpath.substring(0,pos);
    String left=xpath.substring(pos);
    String filteredConcept=conceptName;
    filteredConcept+="String_Node_Str" + value + "String_Node_Str";
    xpath=filteredConcept + left;
    xpaths[i]=xpath;
  }
  String[] results=Util.getPort().xPathsSearch(new WSXPathsSearch(new WSDataClusterPK(config.getCluster()),xpaths[0],new WSStringArray(xpaths),null,-1,0,Integer.MAX_VALUE,null,null)).getStrings();
  if (results == null)   results=new String[0];
  JSONObject json=new JSONObject();
  json.put("String_Node_Str",results.length);
  JSONArray rows=new JSONArray();
  json.put("String_Node_Str",rows);
  for (int i=0; i < results.length; i++) {
    if (results[i] != null) {
      Document d=Util.parse(results[i]);
      String tmp="String_Node_Str";
      for (int j=0; j < xpaths.length; j++) {
        tmp+="String_Node_Str" + Util.getFirstTextNode(d,"String_Node_Str" + xpaths[j].split("String_Node_Str")[xpaths[j].split("String_Node_Str").length - 1]);
      }
      if (Util.getFirstTextNode(d,"String_Node_Str" + xpathForeignKey.split("String_Node_Str")[xpathForeignKey.split("String_Node_Str").length - 1]) != null) {
        String keys=Util.getFirstTextNode(d,"String_Node_Str" + xpathForeignKey.split("String_Node_Str")[xpathForeignKey.split("String_Node_Str").length - 1]);
        String infos=tmp.substring(3);
        JSONObject row=new JSONObject();
        row.put("String_Node_Str",keys);
        row.put("String_Node_Str",infos);
        rows.put(row);
      }
    }
  }
  return json.toString();
}