Program: 89294
Project: 89294
Buggy source:
private void generateEmailAlert(DataCenterVO dc,HostPodVO pod,ClusterVO cluster,double totalCapacity,double usedCapacity,short capacityType){
  String msgSubject=null;
  String msgContent=null;
  String totalStr;
  String usedStr;
  String pctStr=formatPercent(usedCapacity / totalCapacity);
  short alertType=-1;
  Long podId=pod == null ? null : pod.getId();
  Long clusterId=cluster == null ? null : cluster.getId();
switch (capacityType) {
case CapacityVO.CAPACITY_TYPE_MEMORY:
    msgSubject="String_Node_Str" + cluster.getName() + "String_Node_Str"+ pod.getName()+ "String_Node_Str"+ dc.getName();
  totalStr=formatBytesToMegabytes(totalCapacity);
usedStr=formatBytesToMegabytes(usedCapacity);
msgContent="String_Node_Str" + totalStr + "String_Node_Str"+ usedStr+ "String_Node_Str"+ pctStr+ "String_Node_Str";
alertType=ALERT_TYPE_MEMORY;
break;
case CapacityVO.CAPACITY_TYPE_CPU:
msgSubject="String_Node_Str" + cluster.getName() + "String_Node_Str"+ pod.getName()+ "String_Node_Str"+ dc.getName();
totalStr=_dfWhole.format(totalCapacity);
usedStr=_dfWhole.format(usedCapacity);
msgContent="String_Node_Str" + totalStr + "String_Node_Str"+ usedStr+ "String_Node_Str"+ pctStr+ "String_Node_Str";
alertType=ALERT_TYPE_CPU;
break;
case CapacityVO.CAPACITY_TYPE_STORAGE:
msgSubject="String_Node_Str" + cluster.getName() + "String_Node_Str"+ pod.getName()+ "String_Node_Str"+ dc.getName();
totalStr=formatBytesToMegabytes(totalCapacity);
usedStr=formatBytesToMegabytes(usedCapacity);
msgContent="String_Node_Str" + totalStr + "String_Node_Str"+ usedStr+ "String_Node_Str"+ pctStr+ "String_Node_Str";
alertType=ALERT_TYPE_STORAGE;
break;
case CapacityVO.CAPACITY_TYPE_STORAGE_ALLOCATED:
msgSubject="String_Node_Str" + cluster.getName() + "String_Node_Str"+ pod.getName()+ "String_Node_Str"+ dc.getName();
totalStr=formatBytesToMegabytes(totalCapacity);
usedStr=formatBytesToMegabytes(usedCapacity);
msgContent="String_Node_Str" + totalStr + "String_Node_Str"+ usedStr+ "String_Node_Str"+ pctStr+ "String_Node_Str";
alertType=ALERT_TYPE_STORAGE_ALLOCATED;
break;
case CapacityVO.CAPACITY_TYPE_LOCAL_STORAGE:
msgSubject="String_Node_Str" + cluster.getName() + "String_Node_Str"+ pod.getName()+ "String_Node_Str"+ dc.getName();
totalStr=formatBytesToMegabytes(totalCapacity);
usedStr=formatBytesToMegabytes(usedCapacity);
msgContent="String_Node_Str" + totalStr + "String_Node_Str"+ usedStr+ "String_Node_Str"+ pctStr+ "String_Node_Str";
alertType=ALERT_TYPE_LOCAL_STORAGE;
break;
case CapacityVO.CAPACITY_TYPE_PRIVATE_IP:
msgSubject="String_Node_Str" + pod.getName() + "String_Node_Str"+ dc.getName();
totalStr=Double.toString(totalCapacity);
usedStr=Double.toString(usedCapacity);
msgContent="String_Node_Str" + totalStr + "String_Node_Str"+ usedStr+ "String_Node_Str"+ pctStr+ "String_Node_Str";
alertType=ALERT_TYPE_PRIVATE_IP;
break;
case CapacityVO.CAPACITY_TYPE_SECONDARY_STORAGE:
msgSubject="String_Node_Str" + dc.getName();
totalStr=formatBytesToMegabytes(totalCapacity);
usedStr=formatBytesToMegabytes(usedCapacity);
msgContent="String_Node_Str" + totalStr + "String_Node_Str"+ usedStr+ "String_Node_Str"+ pctStr+ "String_Node_Str";
alertType=ALERT_TYPE_SECONDARY_STORAGE;
break;
case CapacityVO.CAPACITY_TYPE_VIRTUAL_NETWORK_PUBLIC_IP:
msgSubject="String_Node_Str" + dc.getName();
totalStr=Double.toString(totalCapacity);
usedStr=Double.toString(usedCapacity);
msgContent="String_Node_Str" + totalStr + "String_Node_Str"+ usedStr+ "String_Node_Str"+ pctStr+ "String_Node_Str";
alertType=ALERT_TYPE_VIRTUAL_NETWORK_PUBLIC_IP;
break;
case CapacityVO.CAPACITY_TYPE_DIRECT_ATTACHED_PUBLIC_IP:
msgSubject="String_Node_Str" + dc.getName();
totalStr=Double.toString(totalCapacity);
usedStr=Double.toString(usedCapacity);
msgContent="String_Node_Str" + totalStr + "String_Node_Str"+ usedStr+ "String_Node_Str"+ pctStr+ "String_Node_Str";
alertType=ALERT_TYPE_DIRECT_ATTACHED_PUBLIC_IP;
break;
case CapacityVO.CAPACITY_TYPE_VLAN:
msgSubject="String_Node_Str" + dc.getName();
totalStr=Double.toString(totalCapacity);
usedStr=Double.toString(usedCapacity);
msgContent="String_Node_Str" + totalStr + "String_Node_Str"+ usedStr+ "String_Node_Str"+ pctStr+ "String_Node_Str";
alertType=ALERT_TYPE_VLAN;
break;
}
try {
_emailAlert.sendAlert(alertType,dc.getId(),podId,clusterId,msgSubject,msgContent);
}
 catch (Exception ex) {
s_logger.error("String_Node_Str",ex);
}
}

Fixed version (ground truth):
private void generateEmailAlert(DataCenterVO dc,HostPodVO pod,ClusterVO cluster,double totalCapacity,double usedCapacity,short capacityType){
  String msgSubject=null;
  String msgContent=null;
  String totalStr;
  String usedStr;
  String pctStr=formatPercent(usedCapacity / totalCapacity);
  short alertType=-1;
  Long podId=pod == null ? null : pod.getId();
  Long clusterId=cluster == null ? null : cluster.getId();
switch (capacityType) {
case CapacityVO.CAPACITY_TYPE_MEMORY:
    msgSubject="String_Node_Str" + cluster.getName() + "String_Node_Str"+ pod.getName()+ "String_Node_Str"+ dc.getName();
  totalStr=formatBytesToMegabytes(totalCapacity);
usedStr=formatBytesToMegabytes(usedCapacity);
msgContent="String_Node_Str" + totalStr + "String_Node_Str"+ usedStr+ "String_Node_Str"+ pctStr+ "String_Node_Str";
alertType=ALERT_TYPE_MEMORY;
break;
case CapacityVO.CAPACITY_TYPE_CPU:
msgSubject="String_Node_Str" + cluster.getName() + "String_Node_Str"+ pod.getName()+ "String_Node_Str"+ dc.getName();
totalStr=_dfWhole.format(totalCapacity);
usedStr=_dfWhole.format(usedCapacity);
msgContent="String_Node_Str" + totalStr + "String_Node_Str"+ usedStr+ "String_Node_Str"+ pctStr+ "String_Node_Str";
alertType=ALERT_TYPE_CPU;
break;
case CapacityVO.CAPACITY_TYPE_STORAGE:
msgSubject="String_Node_Str" + cluster.getName() + "String_Node_Str"+ pod.getName()+ "String_Node_Str"+ dc.getName();
totalStr=formatBytesToMegabytes(totalCapacity);
usedStr=formatBytesToMegabytes(usedCapacity);
msgContent="String_Node_Str" + totalStr + "String_Node_Str"+ usedStr+ "String_Node_Str"+ pctStr+ "String_Node_Str";
alertType=ALERT_TYPE_STORAGE;
break;
case CapacityVO.CAPACITY_TYPE_STORAGE_ALLOCATED:
msgSubject="String_Node_Str" + cluster.getName() + "String_Node_Str"+ pod.getName()+ "String_Node_Str"+ dc.getName();
totalStr=formatBytesToMegabytes(totalCapacity);
usedStr=formatBytesToMegabytes(usedCapacity);
msgContent="String_Node_Str" + totalStr + "String_Node_Str"+ usedStr+ "String_Node_Str"+ pctStr+ "String_Node_Str";
alertType=ALERT_TYPE_STORAGE_ALLOCATED;
break;
case CapacityVO.CAPACITY_TYPE_LOCAL_STORAGE:
msgSubject="String_Node_Str" + cluster.getName() + "String_Node_Str"+ pod.getName()+ "String_Node_Str"+ dc.getName();
totalStr=formatBytesToMegabytes(totalCapacity);
usedStr=formatBytesToMegabytes(usedCapacity);
msgContent="String_Node_Str" + totalStr + "String_Node_Str"+ usedStr+ "String_Node_Str"+ pctStr+ "String_Node_Str";
alertType=ALERT_TYPE_LOCAL_STORAGE;
break;
case CapacityVO.CAPACITY_TYPE_PRIVATE_IP:
msgSubject="String_Node_Str" + pod.getName() + "String_Node_Str"+ dc.getName();
totalStr=Double.toString(totalCapacity);
usedStr=Double.toString(usedCapacity);
msgContent="String_Node_Str" + totalStr + "String_Node_Str"+ usedStr+ "String_Node_Str"+ pctStr+ "String_Node_Str";
alertType=ALERT_TYPE_PRIVATE_IP;
break;
case CapacityVO.CAPACITY_TYPE_SECONDARY_STORAGE:
msgSubject="String_Node_Str" + dc.getName();
totalStr=formatBytesToMegabytes(totalCapacity);
usedStr=formatBytesToMegabytes(usedCapacity);
msgContent="String_Node_Str" + totalStr + "String_Node_Str"+ usedStr+ "String_Node_Str"+ pctStr+ "String_Node_Str";
alertType=ALERT_TYPE_SECONDARY_STORAGE;
break;
case CapacityVO.CAPACITY_TYPE_VIRTUAL_NETWORK_PUBLIC_IP:
msgSubject="String_Node_Str" + dc.getName();
totalStr=Double.toString(totalCapacity);
usedStr=Double.toString(usedCapacity);
msgContent="String_Node_Str" + totalStr + "String_Node_Str"+ usedStr+ "String_Node_Str"+ pctStr+ "String_Node_Str";
alertType=ALERT_TYPE_VIRTUAL_NETWORK_PUBLIC_IP;
break;
case CapacityVO.CAPACITY_TYPE_DIRECT_ATTACHED_PUBLIC_IP:
msgSubject="String_Node_Str" + dc.getName();
totalStr=Double.toString(totalCapacity);
usedStr=Double.toString(usedCapacity);
msgContent="String_Node_Str" + totalStr + "String_Node_Str"+ usedStr+ "String_Node_Str"+ pctStr+ "String_Node_Str";
alertType=ALERT_TYPE_DIRECT_ATTACHED_PUBLIC_IP;
break;
case CapacityVO.CAPACITY_TYPE_VLAN:
msgSubject="String_Node_Str" + dc.getName();
totalStr=Double.toString(totalCapacity);
usedStr=Double.toString(usedCapacity);
msgContent="String_Node_Str" + totalStr + "String_Node_Str"+ usedStr+ "String_Node_Str"+ pctStr+ "String_Node_Str";
alertType=ALERT_TYPE_VLAN;
break;
}
try {
if (s_logger.isDebugEnabled()) {
s_logger.debug(msgSubject);
s_logger.debug(msgContent);
}
_emailAlert.sendAlert(alertType,dc.getId(),podId,clusterId,msgSubject,msgContent);
}
 catch (Exception ex) {
s_logger.error("String_Node_Str",ex);
}
}