Program: 89695
Project: 89695
Buggy source:
protected HashMap<String,VmStatsEntry> getVmStats(Connection conn,GetVmStatsCommand cmd,List<String> vmUUIDs,String hostGuid){
  HashMap<String,VmStatsEntry> vmResponseMap=new HashMap<String,VmStatsEntry>();
  for (  String vmUUID : vmUUIDs) {
    vmResponseMap.put(vmUUID,new VmStatsEntry(0,0,0,0,"String_Node_Str"));
  }
  Object[] rrdData=getRRDData(conn,2);
  if (rrdData == null) {
    return null;
  }
  Integer numRows=(Integer)rrdData[0];
  Integer numColumns=(Integer)rrdData[1];
  Node legend=(Node)rrdData[2];
  Node dataNode=(Node)rrdData[3];
  NodeList legendChildren=legend.getChildNodes();
  for (int col=0; col < numColumns; col++) {
    if (legendChildren == null || legendChildren.item(col) == null) {
      continue;
    }
    String columnMetadata=getXMLNodeValue(legendChildren.item(col));
    if (columnMetadata == null) {
      continue;
    }
    String[] columnMetadataList=columnMetadata.split("String_Node_Str");
    if (columnMetadataList.length != 4) {
      continue;
    }
    String type=columnMetadataList[1];
    String uuid=columnMetadataList[2];
    String param=columnMetadataList[3];
    if (type.equals("String_Node_Str") && vmResponseMap.keySet().contains(uuid)) {
      VmStatsEntry vmStatsAnswer=vmResponseMap.get(uuid);
      vmStatsAnswer.setEntityType("String_Node_Str");
      if (param.contains("String_Node_Str")) {
        vmStatsAnswer.setNumCPUs(vmStatsAnswer.getNumCPUs() + 1);
        vmStatsAnswer.setCPUUtilization((vmStatsAnswer.getCPUUtilization() + getDataAverage(dataNode,col,numRows)) * 100);
      }
 else       if (param.equals("String_Node_Str")) {
        vmStatsAnswer.setNetworkReadKBs(getDataAverage(dataNode,col,numRows) / (8 * 2));
      }
 else       if (param.equals("String_Node_Str")) {
        vmStatsAnswer.setNetworkWriteKBs(getDataAverage(dataNode,col,numRows) / (8 * 2));
      }
    }
  }
  for (  String vmUUID : vmResponseMap.keySet()) {
    VmStatsEntry vmStatsAnswer=vmResponseMap.get(vmUUID);
    if (vmStatsAnswer.getNumCPUs() != 0) {
      vmStatsAnswer.setCPUUtilization(vmStatsAnswer.getCPUUtilization() / vmStatsAnswer.getNumCPUs());
      s_logger.debug("String_Node_Str" + vmStatsAnswer.getCPUUtilization());
    }
  }
  return vmResponseMap;
}

Fixed version (ground truth):
protected HashMap<String,VmStatsEntry> getVmStats(Connection conn,GetVmStatsCommand cmd,List<String> vmUUIDs,String hostGuid){
  HashMap<String,VmStatsEntry> vmResponseMap=new HashMap<String,VmStatsEntry>();
  for (  String vmUUID : vmUUIDs) {
    vmResponseMap.put(vmUUID,new VmStatsEntry(0,0,0,0,"String_Node_Str"));
  }
  Object[] rrdData=getRRDData(conn,2);
  if (rrdData == null) {
    return null;
  }
  Integer numRows=(Integer)rrdData[0];
  Integer numColumns=(Integer)rrdData[1];
  Node legend=(Node)rrdData[2];
  Node dataNode=(Node)rrdData[3];
  NodeList legendChildren=legend.getChildNodes();
  for (int col=0; col < numColumns; col++) {
    if (legendChildren == null || legendChildren.item(col) == null) {
      continue;
    }
    String columnMetadata=getXMLNodeValue(legendChildren.item(col));
    if (columnMetadata == null) {
      continue;
    }
    String[] columnMetadataList=columnMetadata.split("String_Node_Str");
    if (columnMetadataList.length != 4) {
      continue;
    }
    String type=columnMetadataList[1];
    String uuid=columnMetadataList[2];
    String param=columnMetadataList[3];
    if (type.equals("String_Node_Str") && vmResponseMap.keySet().contains(uuid)) {
      VmStatsEntry vmStatsAnswer=vmResponseMap.get(uuid);
      vmStatsAnswer.setEntityType("String_Node_Str");
      if (param.contains("String_Node_Str")) {
        vmStatsAnswer.setNumCPUs(vmStatsAnswer.getNumCPUs() + 1);
        vmStatsAnswer.setCPUUtilization(((vmStatsAnswer.getCPUUtilization() + getDataAverage(dataNode,col,numRows))));
      }
 else       if (param.equals("String_Node_Str")) {
        vmStatsAnswer.setNetworkReadKBs(getDataAverage(dataNode,col,numRows) / (8 * 2));
      }
 else       if (param.equals("String_Node_Str")) {
        vmStatsAnswer.setNetworkWriteKBs(getDataAverage(dataNode,col,numRows) / (8 * 2));
      }
    }
  }
  for (  String vmUUID : vmResponseMap.keySet()) {
    VmStatsEntry vmStatsAnswer=vmResponseMap.get(vmUUID);
    if (vmStatsAnswer.getNumCPUs() != 0) {
      vmStatsAnswer.setCPUUtilization(vmStatsAnswer.getCPUUtilization() / vmStatsAnswer.getNumCPUs());
    }
    vmStatsAnswer.setCPUUtilization(vmStatsAnswer.getCPUUtilization() * 100);
    if (s_logger.isDebugEnabled())     s_logger.debug("String_Node_Str" + vmStatsAnswer.getCPUUtilization());
  }
  return vmResponseMap;
}