Program: 105160
Project: 105160
Buggy source:
public HashMap<String,VmStatsEntry> getVmStats(final Connection conn,final GetVmStatsCommand cmd,final List<String> vmUUIDs,final String hostGuid){
  final HashMap<String,VmStatsEntry> vmResponseMap=new HashMap<String,VmStatsEntry>();
  for (  final String vmUUID : vmUUIDs) {
    vmResponseMap.put(vmUUID,new VmStatsEntry(0,0,0,0,0,0,0,"String_Node_Str"));
  }
  final Object[] rrdData=getRRDData(conn,2);
  if (rrdData == null) {
    return null;
  }
  final Integer numRows=(Integer)rrdData[0];
  final Integer numColumns=(Integer)rrdData[1];
  final Node legend=(Node)rrdData[2];
  final Node dataNode=(Node)rrdData[3];
  final NodeList legendChildren=legend.getChildNodes();
  for (int col=0; col < numColumns; col++) {
    if (legendChildren == null || legendChildren.item(col) == null) {
      continue;
    }
    final String columnMetadata=getXMLNodeValue(legendChildren.item(col));
    if (columnMetadata == null) {
      continue;
    }
    final String[] columnMetadataList=columnMetadata.split("String_Node_Str");
    if (columnMetadataList.length != 4) {
      continue;
    }
    final String type=columnMetadataList[1];
    final String uuid=columnMetadataList[2];
    final String param=columnMetadataList[3];
    if (type.equals("String_Node_Str") && vmResponseMap.keySet().contains(uuid)) {
      final 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.matches("String_Node_Str")) {
        vmStatsAnswer.setNetworkReadKBs(vmStatsAnswer.getNetworkReadKBs() + getDataAverage(dataNode,col,numRows) / 1000);
      }
 else       if (param.matches("String_Node_Str")) {
        vmStatsAnswer.setNetworkWriteKBs(vmStatsAnswer.getNetworkWriteKBs() + getDataAverage(dataNode,col,numRows) / 1000);
      }
 else       if (param.matches("String_Node_Str")) {
        vmStatsAnswer.setDiskReadKBs(vmStatsAnswer.getDiskReadKBs() + getDataAverage(dataNode,col,numRows) / 1000);
      }
 else       if (param.matches("String_Node_Str")) {
        vmStatsAnswer.setDiskWriteKBs(vmStatsAnswer.getDiskWriteKBs() + getDataAverage(dataNode,col,numRows) / 1000);
      }
 else       if (param.contains("String_Node_Str")) {
        vmStatsAnswer.setIntFreeMemoryKBs(vmStatsAnswer.getIntFreeMemoryKBs() + getDataAverage(dataNode,col,numRows) / 1024);
      }
 else       if (param.contains("String_Node_Str")) {
        vmStatsAnswer.setTargetMemoryKBs(vmStatsAnswer.getTargetMemoryKBs() + getDataAverage(dataNode,col,numRows) / 1024);
      }
 else       if (param.contains("String_Node_Str")) {
        vmStatsAnswer.setMemoryKBs(vmStatsAnswer.getMemoryKBs() + getDataAverage(dataNode,col,numRows) / 1024);
      }
    }
  }
  for (  final Map.Entry<String,VmStatsEntry> entry : vmResponseMap.entrySet()) {
    final VmStatsEntry vmStatsAnswer=entry.getValue();
    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;
}

Fixed version (ground truth):
public HashMap<String,VmStatsEntry> getVmStats(final Connection conn,final GetVmStatsCommand cmd,final List<String> vmUUIDs,final String hostGuid){
  final HashMap<String,VmStatsEntry> vmResponseMap=new HashMap<String,VmStatsEntry>();
  for (  final String vmUUID : vmUUIDs) {
    vmResponseMap.put(vmUUID,new VmStatsEntry(0,0,0,0,0,0,0,"String_Node_Str"));
  }
  final Object[] rrdData=getRRDData(conn,2);
  if (rrdData == null) {
    return null;
  }
  final Integer numRows=(Integer)rrdData[0];
  final Integer numColumns=(Integer)rrdData[1];
  final Node legend=(Node)rrdData[2];
  final Node dataNode=(Node)rrdData[3];
  final NodeList legendChildren=legend.getChildNodes();
  for (int col=0; col < numColumns; col++) {
    if (legendChildren == null || legendChildren.item(col) == null) {
      continue;
    }
    final String columnMetadata=getXMLNodeValue(legendChildren.item(col));
    if (columnMetadata == null) {
      continue;
    }
    final String[] columnMetadataList=columnMetadata.split("String_Node_Str");
    if (columnMetadataList.length != 4) {
      continue;
    }
    final String type=columnMetadataList[1];
    final String uuid=columnMetadataList[2];
    final String param=columnMetadataList[3];
    if (type.equals("String_Node_Str") && vmResponseMap.keySet().contains(uuid)) {
      final 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.matches("String_Node_Str")) {
        vmStatsAnswer.setNetworkReadKBs(vmStatsAnswer.getNetworkReadKBs() + getDataAverage(dataNode,col,numRows) / BASE_TO_CONVERT_BYTES_INTO_KILOBYTES);
      }
 else       if (param.matches("String_Node_Str")) {
        vmStatsAnswer.setNetworkWriteKBs(vmStatsAnswer.getNetworkWriteKBs() + getDataAverage(dataNode,col,numRows) / BASE_TO_CONVERT_BYTES_INTO_KILOBYTES);
      }
 else       if (param.matches("String_Node_Str")) {
        vmStatsAnswer.setDiskReadKBs(vmStatsAnswer.getDiskReadKBs() + getDataAverage(dataNode,col,numRows) / BASE_TO_CONVERT_BYTES_INTO_KILOBYTES);
      }
 else       if (param.matches("String_Node_Str")) {
        vmStatsAnswer.setDiskWriteKBs(vmStatsAnswer.getDiskWriteKBs() + getDataAverage(dataNode,col,numRows) / BASE_TO_CONVERT_BYTES_INTO_KILOBYTES);
      }
 else       if (param.contains("String_Node_Str")) {
        vmStatsAnswer.setIntFreeMemoryKBs(vmStatsAnswer.getIntFreeMemoryKBs() + getDataAverage(dataNode,col,numRows) / BASE_TO_CONVERT_BYTES_INTO_KILOBYTES);
      }
 else       if (param.contains("String_Node_Str")) {
        vmStatsAnswer.setTargetMemoryKBs(vmStatsAnswer.getTargetMemoryKBs() + getDataAverage(dataNode,col,numRows) / BASE_TO_CONVERT_BYTES_INTO_KILOBYTES);
      }
 else       if (param.contains("String_Node_Str")) {
        vmStatsAnswer.setMemoryKBs(vmStatsAnswer.getMemoryKBs() + getDataAverage(dataNode,col,numRows) / BASE_TO_CONVERT_BYTES_INTO_KILOBYTES);
      }
    }
  }
  for (  final Map.Entry<String,VmStatsEntry> entry : vmResponseMap.entrySet()) {
    final VmStatsEntry vmStatsAnswer=entry.getValue();
    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;
}