Program: 146078
Project: 146078
Buggy source:
protected void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  org.apache.log4j.Logger.getLogger(this.getClass()).trace("String_Node_Str");
  request.setCharacterEncoding("String_Node_Str");
  response.setContentType("String_Node_Str");
  Configuration config=null;
  try {
    org.apache.log4j.Logger.getLogger(this.getClass()).trace("String_Node_Str" + request.getSession().getId());
    config=(Configuration)request.getSession().getAttribute("String_Node_Str");
    if (config == null) {
      org.apache.log4j.Logger.getLogger(this.getClass()).debug("String_Node_Str");
    }
  }
 catch (  Exception e1) {
    e1.printStackTrace();
  }
  String start=request.getParameter("String_Node_Str");
  String limit=request.getParameter("String_Node_Str");
  String sortCol=(request.getParameter("String_Node_Str") != null ? request.getParameter("String_Node_Str") : "String_Node_Str");
  String sortDir=(request.getParameter("String_Node_Str") != null ? request.getParameter("String_Node_Str") : "String_Node_Str");
  String viewName=request.getParameter("String_Node_Str");
  String criteria=request.getParameter("String_Node_Str");
  org.apache.log4j.Logger.getLogger(this.getClass()).debug("String_Node_Str" + "String_Node_Str" + start + "String_Node_Str"+ "String_Node_Str"+ limit+ "String_Node_Str"+ "String_Node_Str"+ criteria+ "String_Node_Str"+ "String_Node_Str"+ viewName+ "String_Node_Str"+ "String_Node_Str"+ sortCol+ "String_Node_Str"+ "String_Node_Str"+ sortDir);
  JSONObject json=new JSONObject();
  String[] results;
  ArrayList<String[]> itemsBrowserContent=new ArrayList<String[]>();
  try {
    int max=Integer.parseInt(limit);
    int skip=Integer.parseInt(start);
    View view=new View(viewName);
    org.apache.log4j.Logger.getLogger(this.getClass()).debug("String_Node_Str");
    ArrayList<WSWhereItem> conditions=new ArrayList<WSWhereItem>();
    WSWhereItem wi;
    String[] filters=criteria.split("String_Node_Str");
    String[] filterXpaths=new String[filters.length];
    String[] filterOperators=new String[filters.length];
    String[] filterValues=new String[filters.length];
    for (int i=0; i < filters.length; i++) {
      if (filters[i].split("String_Node_Str").length > 2) {
        filterXpaths[i]=filters[i].split("String_Node_Str")[0];
        filterOperators[i]=filters[i].split("String_Node_Str")[1];
        filterValues[i]=filters[i].split("String_Node_Str")[2];
      }
    }
    for (int i=0; i < filterValues.length; i++) {
      if ((filterValues[i] == null) || ("String_Node_Str".equals(filterValues[i])) || "String_Node_Str".equals(filterValues[i])) {
        continue;
      }
      WSWhereCondition wc=new WSWhereCondition(filterXpaths[i],getOperator(filterOperators[i]),filterValues[i],WSStringPredicate.NONE,false);
      WSWhereItem item=new WSWhereItem(wc,null,null);
      conditions.add(item);
    }
    if (conditions.size() == 0) {
      wi=null;
    }
 else {
      WSWhereAnd and=new WSWhereAnd(conditions.toArray(new WSWhereItem[conditions.size()]));
      wi=new WSWhereItem(null,and,null);
    }
    if ("String_Node_Str".equals(filterXpaths[0])) {
      results=Util.getPort().viewSearch(new WSViewSearch(new WSDataClusterPK(config.getCluster()),new WSViewPK(view.getViewPK()),wi,-1,skip,max,null,null)).getStrings();
    }
 else {
      org.apache.log4j.Logger.getLogger(this.getClass()).trace("String_Node_Str");
      results=Util.getPort().viewSearch(new WSViewSearch(new WSDataClusterPK(config.getCluster()),new WSViewPK(view.getViewPK()),wi,-1,skip,max,null,null)).getStrings();
      org.apache.log4j.Logger.getLogger(this.getClass()).trace("String_Node_Str");
    }
    for (int i=0; i < results.length; i++) {
      results[i]=results[i].replaceAll("String_Node_Str","String_Node_Str");
      results[i]=results[i].replaceAll("String_Node_Str","String_Node_Str");
      results[i]=openingTags.matcher(results[i]).replaceAll("String_Node_Str");
      results[i]=closingTags.matcher(results[i]).replaceAll("String_Node_Str");
      results[i]=emptyTags.matcher(results[i]).replaceAll("String_Node_Str");
      String[] elements=results[i].split("String_Node_Str");
      String[] fields=new String[view.getViewables().length];
      int count=Math.min(elements.length,fields.length);
      for (int j=0; j < count; j++) {
        fields[j]=StringEscapeUtils.unescapeXml(elements[j]);
      }
      itemsBrowserContent.add(fields);
    }
    int totalCount=(Integer)request.getSession().getAttribute("String_Node_Str");
    org.apache.log4j.Logger.getLogger(this.getClass()).debug("String_Node_Str" + totalCount);
    int tmp=0;
    for (int i=0; i < view.getViewables().length; i++) {
      org.apache.log4j.Logger.getLogger(this.getClass()).debug("String_Node_Str" + sortCol + "String_Node_Str"+ view.getViewables()[i]+ "String_Node_Str"+ i);
      if (sortCol.equals("String_Node_Str" + view.getViewables()[i])) {
        tmp=i;
        break;
      }
    }
    final int column=tmp;
    final String direction=sortDir;
    Comparator sort;
    if (direction.equals("String_Node_Str")) {
      sort=new Comparator(){
        public int compare(        Object o1,        Object o2){
          try {
            Double test=(Double.parseDouble(((String[])o1)[column]) - Double.parseDouble(((String[])o2)[column]));
            return test.intValue();
          }
 catch (          Exception e) {
          }
          try {
            return (((String[])o1)[column]).compareTo(((String[])o2)[column]);
          }
 catch (          Exception e) {
            return 0;
          }
        }
      }
;
    }
 else {
      sort=new Comparator(){
        public int compare(        Object o1,        Object o2){
          try {
            Double test=(Double.parseDouble(((String[])o2)[column]) - Double.parseDouble(((String[])o1)[column]));
            return test.intValue();
          }
 catch (          Exception e) {
          }
          try {
            return (((String[])o2)[column]).compareTo(((String[])o1)[column]);
          }
 catch (          Exception e) {
            return 0;
          }
        }
      }
;
    }
    org.apache.log4j.Logger.getLogger(this.getClass()).debug("String_Node_Str");
    Collections.sort(itemsBrowserContent,sort);
    if (max > totalCount)     max=totalCount;
    if (max > (totalCount - skip)) {
      max=totalCount - skip;
    }
    org.apache.log4j.Logger.getLogger(this.getClass()).debug("String_Node_Str");
    json.put("String_Node_Str",totalCount);
    ArrayList<JSONObject> rows=new ArrayList<JSONObject>();
    for (int i=skip; i < (max + skip); i++) {
      JSONObject fields=new JSONObject();
      for (int j=0; j < itemsBrowserContent.get(i - skip).length; j++) {
        fields.put("String_Node_Str" + view.getViewables()[j],itemsBrowserContent.get(i - skip)[j]);
      }
      rows.add(fields);
    }
    json.put("String_Node_Str",rows);
    json.put("String_Node_Str",true);
    org.apache.log4j.Logger.getLogger(this.getClass()).debug(json);
  }
 catch (  XtentisWebappException e) {
    e.printStackTrace();
  }
catch (  Exception e) {
    e.printStackTrace();
  }
  PrintWriter writer=response.getWriter();
  writer.write(json.toString());
  writer.close();
}

Fixed version (ground truth):
protected void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  org.apache.log4j.Logger.getLogger(this.getClass()).trace("String_Node_Str");
  request.setCharacterEncoding("String_Node_Str");
  response.setContentType("String_Node_Str");
  Configuration config=null;
  try {
    org.apache.log4j.Logger.getLogger(this.getClass()).trace("String_Node_Str" + request.getSession().getId());
    config=(Configuration)request.getSession().getAttribute("String_Node_Str");
    if (config == null) {
      org.apache.log4j.Logger.getLogger(this.getClass()).debug("String_Node_Str");
    }
  }
 catch (  Exception e1) {
    e1.printStackTrace();
  }
  String start=request.getParameter("String_Node_Str");
  String limit=request.getParameter("String_Node_Str");
  String sortCol=(request.getParameter("String_Node_Str") != null ? request.getParameter("String_Node_Str") : "String_Node_Str");
  String sortDir=(request.getParameter("String_Node_Str") != null ? request.getParameter("String_Node_Str") : "String_Node_Str");
  String viewName=request.getParameter("String_Node_Str");
  String criteria=request.getParameter("String_Node_Str");
  org.apache.log4j.Logger.getLogger(this.getClass()).debug("String_Node_Str" + "String_Node_Str" + start + "String_Node_Str"+ "String_Node_Str"+ limit+ "String_Node_Str"+ "String_Node_Str"+ criteria+ "String_Node_Str"+ "String_Node_Str"+ viewName+ "String_Node_Str"+ "String_Node_Str"+ sortCol+ "String_Node_Str"+ "String_Node_Str"+ sortDir);
  JSONObject json=new JSONObject();
  String[] results;
  ArrayList<String[]> itemsBrowserContent=new ArrayList<String[]>();
  try {
    int max=Integer.parseInt(limit);
    int skip=Integer.parseInt(start);
    View view=new View(viewName);
    org.apache.log4j.Logger.getLogger(this.getClass()).debug("String_Node_Str");
    ArrayList<WSWhereItem> conditions=new ArrayList<WSWhereItem>();
    WSWhereItem wi;
    String[] filters=criteria.split("String_Node_Str");
    String[] filterXpaths=new String[filters.length];
    String[] filterOperators=new String[filters.length];
    String[] filterValues=new String[filters.length];
    for (int i=0; i < filters.length; i++) {
      if (filters[i].split("String_Node_Str").length > 2) {
        filterXpaths[i]=filters[i].split("String_Node_Str")[0];
        filterOperators[i]=filters[i].split("String_Node_Str")[1];
        filterValues[i]=filters[i].split("String_Node_Str")[2];
      }
    }
    for (int i=0; i < filterValues.length; i++) {
      if ((filterValues[i] == null) || ("String_Node_Str".equals(filterValues[i])) || "String_Node_Str".equals(filterValues[i])) {
        continue;
      }
      WSWhereCondition wc=new WSWhereCondition(filterXpaths[i],getOperator(filterOperators[i]),filterValues[i],WSStringPredicate.NONE,false);
      WSWhereItem item=new WSWhereItem(wc,null,null);
      conditions.add(item);
    }
    if (conditions.size() == 0) {
      wi=null;
    }
 else {
      WSWhereAnd and=new WSWhereAnd(conditions.toArray(new WSWhereItem[conditions.size()]));
      wi=new WSWhereItem(null,and,null);
    }
    if ("String_Node_Str".equals(filterXpaths[0])) {
      results=Util.getPort().viewSearch(new WSViewSearch(new WSDataClusterPK(config.getCluster()),new WSViewPK(view.getViewPK()),wi,-1,skip,max,null,null)).getStrings();
    }
 else {
      org.apache.log4j.Logger.getLogger(this.getClass()).trace("String_Node_Str");
      results=Util.getPort().viewSearch(new WSViewSearch(new WSDataClusterPK(config.getCluster()),new WSViewPK(view.getViewPK()),wi,-1,skip,max,null,null)).getStrings();
      org.apache.log4j.Logger.getLogger(this.getClass()).trace("String_Node_Str");
    }
    for (int i=0; i < results.length; i++) {
      results[i]=results[i].replaceAll("String_Node_Str","String_Node_Str");
      results[i]=results[i].replaceAll("String_Node_Str","String_Node_Str");
      results[i]=openingTags.matcher(results[i]).replaceAll("String_Node_Str");
      results[i]=closingTags.matcher(results[i]).replaceAll("String_Node_Str");
      results[i]=emptyTags.matcher(results[i]).replaceAll("String_Node_Str");
      String[] elements=results[i].split("String_Node_Str");
      String[] fields=new String[view.getViewables().length];
      int count=Math.min(elements.length,fields.length);
      for (int j=0; j < count; j++) {
        fields[j]=StringEscapeUtils.unescapeXml(elements[j]);
      }
      itemsBrowserContent.add(fields);
    }
    int totalCount=(Integer)request.getSession().getAttribute("String_Node_Str");
    org.apache.log4j.Logger.getLogger(this.getClass()).debug("String_Node_Str" + totalCount);
    int tmp=0;
    for (int i=0; i < view.getViewables().length; i++) {
      org.apache.log4j.Logger.getLogger(this.getClass()).debug("String_Node_Str" + sortCol + "String_Node_Str"+ view.getViewables()[i]+ "String_Node_Str"+ i);
      if (sortCol.equals("String_Node_Str" + view.getViewables()[i])) {
        tmp=i;
        break;
      }
    }
    final int column=tmp;
    final String direction=sortDir;
    Comparator sort;
    if (direction.equals("String_Node_Str")) {
      sort=new Comparator(){
        public int compare(        Object o1,        Object o2){
          try {
            Double test=(Double.parseDouble(((String[])o1)[column]) - Double.parseDouble(((String[])o2)[column]));
            return test.intValue();
          }
 catch (          Exception e) {
          }
          try {
            return (((String[])o1)[column]).compareTo(((String[])o2)[column]);
          }
 catch (          Exception e) {
            return 0;
          }
        }
      }
;
    }
 else {
      sort=new Comparator(){
        public int compare(        Object o1,        Object o2){
          try {
            Double test=(Double.parseDouble(((String[])o2)[column]) - Double.parseDouble(((String[])o1)[column]));
            return test.intValue();
          }
 catch (          Exception e) {
          }
          try {
            return (((String[])o2)[column]).compareTo(((String[])o1)[column]);
          }
 catch (          Exception e) {
            return 0;
          }
        }
      }
;
    }
    org.apache.log4j.Logger.getLogger(this.getClass()).debug("String_Node_Str");
    Collections.sort(itemsBrowserContent,sort);
    if (max > totalCount)     max=totalCount;
    if (max > (totalCount - skip)) {
      max=totalCount - skip;
    }
    org.apache.log4j.Logger.getLogger(this.getClass()).debug("String_Node_Str");
    json.put("String_Node_Str",totalCount);
    ArrayList<JSONObject> rows=new ArrayList<JSONObject>();
    for (int i=skip; i < (max + skip); i++) {
      if (i - skip > itemsBrowserContent.size() - 1)       break;
      JSONObject fields=new JSONObject();
      for (int j=0; j < itemsBrowserContent.get(i - skip).length; j++) {
        fields.put("String_Node_Str" + view.getViewables()[j],itemsBrowserContent.get(i - skip)[j]);
      }
      rows.add(fields);
    }
    json.put("String_Node_Str",rows);
    json.put("String_Node_Str",true);
    org.apache.log4j.Logger.getLogger(this.getClass()).debug(json);
  }
 catch (  XtentisWebappException e) {
    e.printStackTrace();
  }
catch (  Exception e) {
    e.printStackTrace();
  }
  PrintWriter writer=response.getWriter();
  writer.write(json.toString());
  writer.close();
}