Program: 105779
Project: 105779
Buggy source:
@Override public Hashtable<Long,UserVmData> listVmDetails(Hashtable<Long,UserVmData> userVmDataHash){
  TransactionLegacy txn=TransactionLegacy.currentTxn();
  PreparedStatement pstmt=null;
  try {
    int curr_index=0;
    List<UserVmData> userVmDataList=new ArrayList(userVmDataHash.values());
    if (userVmDataList.size() > VM_DETAILS_BATCH_SIZE) {
      pstmt=txn.prepareStatement(VM_DETAILS + getQueryBatchAppender(VM_DETAILS_BATCH_SIZE));
      while ((curr_index + VM_DETAILS_BATCH_SIZE) <= userVmDataList.size()) {
        for (int k=1, j=curr_index; j < curr_index + VM_DETAILS_BATCH_SIZE; j++, k++) {
          pstmt.setLong(k,userVmDataList.get(j).getId());
        }
        ResultSet rs=pstmt.executeQuery();
        while (rs.next()) {
          long vm_id=rs.getLong("String_Node_Str");
          UserVmData uvm=userVmDataHash.get(vm_id);
          if (uvm == null) {
            uvm=new UserVmData();
            uvm.setId(vm_id);
          }
          setUserVmData(uvm,rs);
        }
        rs.close();
        curr_index+=VM_DETAILS_BATCH_SIZE;
      }
      if (pstmt != null)       pstmt.close();
    }
    if (curr_index < userVmDataList.size()) {
      int batch_size=(userVmDataList.size() - curr_index);
      pstmt=txn.prepareStatement(VM_DETAILS + getQueryBatchAppender(batch_size));
      for (int k=1, j=curr_index; j < curr_index + batch_size; j++, k++) {
        pstmt.setLong(k,userVmDataList.get(j).getId());
      }
      ResultSet rs=pstmt.executeQuery();
      while (rs.next()) {
        long vm_id=rs.getLong("String_Node_Str");
        UserVmData uvm=userVmDataHash.get(vm_id);
        if (uvm == null) {
          uvm=new UserVmData();
          uvm.setId(vm_id);
        }
        setUserVmData(uvm,rs);
      }
      rs.close();
    }
    if (pstmt != null)     pstmt.close();
    return userVmDataHash;
  }
 catch (  SQLException e) {
    throw new CloudRuntimeException("String_Node_Str" + VM_DETAILS,e);
  }
catch (  Throwable e) {
    throw new CloudRuntimeException("String_Node_Str" + VM_DETAILS,e);
  }
}

Fixed version (ground truth):
@Override public Hashtable<Long,UserVmData> listVmDetails(Hashtable<Long,UserVmData> userVmDataHash){
  TransactionLegacy txn=TransactionLegacy.currentTxn();
  try {
    int curr_index=0;
    List<UserVmData> userVmDataList=new ArrayList(userVmDataHash.values());
    if (userVmDataList.size() > VM_DETAILS_BATCH_SIZE) {
      try (PreparedStatement pstmt=txn.prepareStatement(VM_DETAILS + getQueryBatchAppender(VM_DETAILS_BATCH_SIZE))){
        while ((curr_index + VM_DETAILS_BATCH_SIZE) <= userVmDataList.size()) {
          for (int k=1, j=curr_index; j < curr_index + VM_DETAILS_BATCH_SIZE; j++, k++) {
            pstmt.setLong(k,userVmDataList.get(j).getId());
          }
          try (ResultSet rs=pstmt.executeQuery()){
            while (rs.next()) {
              long vm_id=rs.getLong("String_Node_Str");
              UserVmData uvm=userVmDataHash.get(vm_id);
              if (uvm == null) {
                uvm=new UserVmData();
                uvm.setId(vm_id);
              }
              setUserVmData(uvm,rs);
            }
          }
 catch (          Exception e) {
            s_logger.error("String_Node_Str" + e.getMessage());
            throw new CloudRuntimeException("String_Node_Str" + e.getMessage(),e);
          }
          curr_index+=VM_DETAILS_BATCH_SIZE;
        }
      }
 catch (      Exception e) {
        s_logger.error("String_Node_Str" + e.getMessage());
        throw new CloudRuntimeException("String_Node_Str" + e.getMessage(),e);
      }
      if (pstmt != null)       pstmt.close();
    }
    if (curr_index < userVmDataList.size()) {
      int batch_size=(userVmDataList.size() - curr_index);
      try (PreparedStatement vm_details_pstmt=txn.prepareStatement(VM_DETAILS + getQueryBatchAppender(batch_size))){
        for (int k=1, j=curr_index; j < curr_index + batch_size; j++, k++) {
          vm_details_pstmt.setLong(k,userVmDataList.get(j).getId());
        }
        try (ResultSet rs=vm_details_pstmt.executeQuery()){
          while (rs.next()) {
            long vm_id=rs.getLong("String_Node_Str");
            UserVmData uvm=userVmDataHash.get(vm_id);
            if (uvm == null) {
              uvm=new UserVmData();
              uvm.setId(vm_id);
            }
            setUserVmData(uvm,rs);
          }
        }
 catch (        Exception e) {
          s_logger.error("String_Node_Str" + e.getMessage());
          throw new CloudRuntimeException("String_Node_Str" + e.getMessage(),e);
        }
      }
 catch (      Exception e) {
        s_logger.error("String_Node_Str" + e.getMessage());
        throw new CloudRuntimeException("String_Node_Str" + e.getMessage(),e);
      }
    }
    txn.commit();
    return userVmDataHash;
  }
 catch (  Exception e) {
    s_logger.error("String_Node_Str" + e.getMessage());
    throw new CloudRuntimeException("String_Node_Str",e);
  }
 finally {
    try {
      if (txn != null) {
        txn.close();
      }
    }
 catch (    Exception e) {
      s_logger.error("String_Node_Str" + e.getMessage());
    }
  }
}