Program: 83875
Project: 83875
Buggy source:
/** 
 * Handle a request.
 * @param collector Instance of PerformanceCollector
 * @param responseQueue queue name to send response to
 * @param request The request as a post-json-parsed-hashmap.
 * @return An iterator for sending the response back.
 */
public void handle(PerformanceCollector collector,String responseQueue,HashMap<String,Object> request) throws ProcessTimeoutException {
  String tracer=(String)request.get("String_Node_Str");
  Object protoTrans=request.get("String_Node_Str");
  boolean useTransaction=false;
  if (protoTrans instanceof Boolean) {
    useTransaction=(Boolean)protoTrans;
  }
  if (protoTrans instanceof Integer) {
    if (((Integer)protoTrans) > 0) {
      useTransaction=true;
    }
  }
  if (protoTrans instanceof String) {
    if (((String)protoTrans).equalsIgnoreCase("String_Node_Str")) {
      useTransaction=true;
    }
  }
  Connection conn=null;
  try {
    DateTime dtProcessBy;
    try {
      dtProcessBy=DateTime.parse((String)request.get("String_Node_Str"));
    }
 catch (    Exception e) {
      dtProcessBy=DateTime.now().withDurationAdded(this.durTTLProcessByDefault,1);
    }
    if (dtProcessBy.isBefore(DateTime.now()))     throw new ProcessTimeoutException("String_Node_Str");
    ArrayList<ArrayList<Object>> params=new ArrayList<ArrayList<Object>>();
    ArrayList<Object> rparams=(ArrayList<Object>)request.get("String_Node_Str");
    ArrayList<String> statements=new ArrayList<String>();
    String rname=(String)request.get("String_Node_Str");
    if (rname == null) {
      List<String> names=(List<String>)request.get("String_Node_Str");
      if (names == null) {
        throw new Exception("String_Node_Str");
      }
      statements.addAll(names);
    }
 else {
      statements.add(rname);
    }
    if (statements.size() < 1) {
      throw new Exception("String_Node_Str");
    }
    if (statements.size() > 1) {
      if (!(rparams.get(0) instanceof ArrayList)) {
        throw new Exception("String_Node_Str");
      }
      if (rparams.size() != statements.size()) {
        throw new Exception("String_Node_Str");
      }
    }
    for (int i=0; i < statements.size(); i++) {
      String s=statements.get(i);
      logger.debug("String_Node_Str",s);
      if (statementBook.getPhrase(s) == null) {
        throw new Exception("String_Node_Str" + s + "String_Node_Str");
      }
      List<ParamType> reqParams=statementBook.getParams(s);
      if (reqParams != null) {
        if (rparams == null) {
          throw new Exception("String_Node_Str" + s + "String_Node_Str");
        }
        Object sparam=rparams.get(i);
        if (statements.size() > 1) {
          ArrayList<Object> newlist=(ArrayList<Object>)sparam;
          if (newlist.size() != reqParams.size()) {
            throw new Exception("String_Node_Str" + reqParams.size() + "String_Node_Str"+ newlist.size());
          }
          params.add(newlist);
        }
 else {
          params.add(rparams);
        }
      }
 else {
        params.add(new ArrayList<Object>());
      }
    }
    logger.debug("String_Node_Str",statements.size(),params.size());
    if (params.size() != statements.size()) {
      throw new Exception("String_Node_Str");
    }
    long connStart=System.currentTimeMillis();
    conn=this.ds.getConnection();
    collector.add("String_Node_Str",System.currentTimeMillis() - connStart,tracer);
    if (useTransaction) {
      conn.setAutoCommit(false);
    }
    for (int i=0; i < statements.size(); i++) {
      long start=System.currentTimeMillis();
      String s=statements.get(i);
      PreparedStatement ps=null;
      ResultSet rs=null;
      ArrayList<Object> sparams=params.get(i);
      String sql=statementBook.getPhrase(s);
      try {
        ps=bindAndExecuteQuery(conn,s,sql,sparams);
        rs=ps.getResultSet();
        if (rs != null) {
          collector.add("String_Node_Str",System.currentTimeMillis() - start,tracer);
          JSONResultSetWrapper wrapper=new JSONResultSetWrapper((String)request.get("String_Node_Str"),rs);
          while (wrapper.hasNext()) {
            sendMessage(responseQueue,wrapper.next());
          }
        }
      }
  finally {
        if (ps != null) {
          try {
            ps.close();
          }
 catch (          SQLException e) {
            logger.error("String_Node_Str",e);
          }
        }
        if (rs != null) {
          try {
            rs.close();
          }
 catch (          SQLException e) {
            logger.error("String_Node_Str",e);
          }
        }
      }
    }
    if (dtProcessBy.isBefore(DateTime.now()))     throw new ProcessTimeoutException("String_Node_Str");
    if (useTransaction) {
      logger.debug("String_Node_Str");
      conn.commit();
    }
  }
 catch (  ProcessTimeoutException e) {
    logger.error(e.getMessage());
    throw new ProcessTimeoutException(e.getMessage());
  }
catch (  Exception e) {
    logger.error("String_Node_Str",e);
    JSONObject obj=new JSONObject();
    obj.put("String_Node_Str",e.getMessage());
    if (tracer != null) {
      obj.put("String_Node_Str",tracer);
    }
    sendMessage(responseQueue,obj.toString());
  }
 finally {
    if (conn != null) {
      try {
        conn.setAutoCommit(true);
      }
 catch (      SQLException e) {
        logger.error("String_Node_Str");
      }
      try {
        conn.close();
      }
 catch (      SQLException e) {
        logger.error("String_Node_Str",e);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Handle a request.
 * @param collector Instance of PerformanceCollector
 * @param responseQueue queue name to send response to
 * @param request The request as a post-json-parsed-hashmap.
 * @return An iterator for sending the response back.
 */
public void handle(PerformanceCollector collector,String responseQueue,HashMap<String,Object> request) throws ProcessTimeoutException {
  String tracer=(String)request.get("String_Node_Str");
  Object protoTrans=request.get("String_Node_Str");
  boolean useTransaction=false;
  if (protoTrans instanceof Boolean) {
    useTransaction=(Boolean)protoTrans;
  }
  if (protoTrans instanceof Integer) {
    if (((Integer)protoTrans) > 0) {
      useTransaction=true;
    }
  }
  if (protoTrans instanceof String) {
    if (((String)protoTrans).equalsIgnoreCase("String_Node_Str")) {
      useTransaction=true;
    }
  }
  Connection conn=null;
  try {
    DateTime dtProcessBy;
    try {
      dtProcessBy=DateTime.parse((String)request.get("String_Node_Str"));
    }
 catch (    Exception e) {
      dtProcessBy=DateTime.now().withDurationAdded(this.durTTLProcessByDefault,1);
    }
    if (dtProcessBy.isBefore(DateTime.now()))     throw new ProcessTimeoutException("String_Node_Str");
    ArrayList<ArrayList<Object>> params=new ArrayList<ArrayList<Object>>();
    ArrayList<Object> rparams=(ArrayList<Object>)request.get("String_Node_Str");
    ArrayList<String> statements=new ArrayList<String>();
    String rname=(String)request.get("String_Node_Str");
    if (rname == null) {
      List<String> names=(List<String>)request.get("String_Node_Str");
      if (names == null) {
        throw new Exception("String_Node_Str");
      }
      statements.addAll(names);
    }
 else {
      statements.add(rname);
    }
    if (statements.size() < 1) {
      throw new Exception("String_Node_Str");
    }
    if (statements.size() > 1) {
      if (!(rparams.get(0) instanceof ArrayList)) {
        throw new Exception("String_Node_Str");
      }
      if (rparams.size() != statements.size()) {
        throw new Exception("String_Node_Str");
      }
    }
    for (int i=0; i < statements.size(); i++) {
      String s=statements.get(i);
      logger.debug("String_Node_Str",s);
      if (statementBook.getPhrase(s) == null) {
        throw new Exception("String_Node_Str" + s + "String_Node_Str");
      }
      List<ParamType> reqParams=statementBook.getParams(s);
      if (reqParams != null) {
        if (rparams == null || (rparams.size() < 1)) {
          throw new Exception("String_Node_Str" + s + "String_Node_Str");
        }
        Object sparam=rparams.get(i);
        if (statements.size() > 1) {
          ArrayList<Object> newlist=(ArrayList<Object>)sparam;
          if (newlist.size() != reqParams.size()) {
            throw new Exception("String_Node_Str" + reqParams.size() + "String_Node_Str"+ newlist.size());
          }
          params.add(newlist);
        }
 else {
          if (rparams.size() != reqParams.size()) {
            throw new Exception("String_Node_Str" + reqParams.size() + "String_Node_Str"+ rparams.size());
          }
          params.add(rparams);
        }
      }
 else {
        params.add(new ArrayList<Object>());
      }
    }
    logger.debug("String_Node_Str",statements.size(),params.size());
    if (params.size() != statements.size()) {
      throw new Exception("String_Node_Str");
    }
    long connStart=System.currentTimeMillis();
    conn=this.ds.getConnection();
    collector.add("String_Node_Str",System.currentTimeMillis() - connStart,tracer);
    if (useTransaction) {
      conn.setAutoCommit(false);
    }
    for (int i=0; i < statements.size(); i++) {
      long start=System.currentTimeMillis();
      String s=statements.get(i);
      PreparedStatement ps=null;
      ResultSet rs=null;
      ArrayList<Object> sparams=params.get(i);
      String sql=statementBook.getPhrase(s);
      try {
        ps=bindAndExecuteQuery(conn,s,sql,sparams);
        rs=ps.getResultSet();
        if (rs != null) {
          collector.add("String_Node_Str",System.currentTimeMillis() - start,tracer);
          JSONResultSetWrapper wrapper=new JSONResultSetWrapper((String)request.get("String_Node_Str"),rs);
          while (wrapper.hasNext()) {
            sendMessage(responseQueue,wrapper.next());
          }
        }
      }
  finally {
        if (ps != null) {
          try {
            ps.close();
          }
 catch (          SQLException e) {
            logger.error("String_Node_Str",e);
          }
        }
        if (rs != null) {
          try {
            rs.close();
          }
 catch (          SQLException e) {
            logger.error("String_Node_Str",e);
          }
        }
      }
    }
    if (dtProcessBy.isBefore(DateTime.now()))     throw new ProcessTimeoutException("String_Node_Str");
    if (useTransaction) {
      logger.debug("String_Node_Str");
      conn.commit();
    }
  }
 catch (  ProcessTimeoutException e) {
    logger.error(e.getMessage());
    throw new ProcessTimeoutException(e.getMessage());
  }
catch (  Exception e) {
    logger.error("String_Node_Str",e);
    JSONObject obj=new JSONObject();
    obj.put("String_Node_Str",e.getMessage());
    if (tracer != null) {
      obj.put("String_Node_Str",tracer);
    }
    sendMessage(responseQueue,obj.toString());
  }
 finally {
    if (conn != null) {
      try {
        conn.setAutoCommit(true);
      }
 catch (      SQLException e) {
        logger.error("String_Node_Str");
      }
      try {
        conn.close();
      }
 catch (      SQLException e) {
        logger.error("String_Node_Str",e);
      }
    }
  }
}