Program: 89227
Project: 89227
Buggy source:
@Override @DB @ActionEvent(eventType=EventTypes.EVENT_ZONE_EDIT,eventDescription="String_Node_Str",async=false) public DataCenter editZone(UpdateZoneCmd cmd){
  Long zoneId=cmd.getId();
  String zoneName=cmd.getZoneName();
  String dns1=cmd.getDns1();
  String dns2=cmd.getDns2();
  String internalDns1=cmd.getInternalDns1();
  String internalDns2=cmd.getInternalDns2();
  List<String> dnsSearchOrder=cmd.getDnsSearchOrder();
  Boolean isPublic=cmd.isPublic();
  String allocationStateStr=cmd.getAllocationState();
  String dhcpProvider=cmd.getDhcpProvider();
  Map<?,?> detailsMap=cmd.getDetails();
  String networkDomain=cmd.getDomain();
  Map<String,String> newDetails=new HashMap<String,String>();
  if (detailsMap != null) {
    Collection<?> zoneDetailsCollection=detailsMap.values();
    Iterator<?> iter=zoneDetailsCollection.iterator();
    while (iter.hasNext()) {
      HashMap<?,?> detail=(HashMap<?,?>)iter.next();
      String key=(String)detail.get("String_Node_Str");
      String value=(String)detail.get("String_Node_Str");
      if ((key == null) || (value == null)) {
        throw new InvalidParameterValueException("String_Node_Str");
      }
      newDetails.put(key,value);
    }
  }
  if (dnsSearchOrder != null) {
    for (    String dom : dnsSearchOrder) {
      if (!NetUtils.verifyDomainName(dom)) {
        throw new InvalidParameterValueException("String_Node_Str" + "String_Node_Str");
      }
    }
    newDetails.put(ZoneConfig.DnsSearchOrder.getName(),StringUtils.join(dnsSearchOrder,"String_Node_Str"));
  }
  DataCenterVO zone=_zoneDao.findById(zoneId);
  if (zone == null) {
    throw new InvalidParameterValueException("String_Node_Str" + zoneId);
  }
  if (zoneName == null) {
    zoneName=zone.getName();
  }
  if (!validZone(zoneId)) {
    throw new InvalidParameterValueException("String_Node_Str" + zoneId + "String_Node_Str");
  }
  String oldZoneName=zone.getName();
  if (zoneName == null) {
    zoneName=oldZoneName;
  }
  if (dns1 == null) {
    dns1=zone.getDns1();
  }
  if (dns2 == null) {
    dns2=zone.getDns2();
  }
  if (internalDns1 == null) {
    internalDns1=zone.getInternalDns1();
  }
  if (networkDomain != null) {
    if (!NetUtils.verifyDomainName(networkDomain)) {
      throw new InvalidParameterValueException("String_Node_Str" + "String_Node_Str");
    }
  }
 else {
    networkDomain=zone.getDomain();
  }
  boolean checkForDuplicates=!zoneName.equals(oldZoneName);
  checkZoneParameters(zoneName,dns1,dns2,internalDns1,internalDns2,checkForDuplicates,null,allocationStateStr);
  zone.setName(zoneName);
  zone.setDns1(dns1);
  zone.setDns2(dns2);
  zone.setInternalDns1(internalDns1);
  zone.setInternalDns2(internalDns2);
  zone.setDomain(networkDomain);
  if (isPublic != null && isPublic) {
    zone.setDomainId(null);
    zone.setDomain(null);
  }
  Transaction txn=Transaction.currentTxn();
  txn.start();
  Map<String,String> updatedDetails=new HashMap<String,String>();
  _zoneDao.loadDetails(zone);
  if (zone.getDetails() != null) {
    updatedDetails.putAll(zone.getDetails());
  }
  updatedDetails.putAll(newDetails);
  zone.setDetails(updatedDetails);
  if (allocationStateStr != null && !allocationStateStr.isEmpty()) {
    Grouping.AllocationState allocationState=Grouping.AllocationState.valueOf(allocationStateStr);
    zone.setAllocationState(allocationState);
  }
  if (dhcpProvider != null) {
    zone.setDhcpProvider(dhcpProvider);
  }
  if (!_zoneDao.update(zoneId,zone)) {
    throw new CloudRuntimeException("String_Node_Str");
  }
  txn.commit();
  return zone;
}

Fixed version (ground truth):
@Override @DB @ActionEvent(eventType=EventTypes.EVENT_ZONE_EDIT,eventDescription="String_Node_Str",async=false) public DataCenter editZone(UpdateZoneCmd cmd){
  Long zoneId=cmd.getId();
  String zoneName=cmd.getZoneName();
  String dns1=cmd.getDns1();
  String dns2=cmd.getDns2();
  String internalDns1=cmd.getInternalDns1();
  String internalDns2=cmd.getInternalDns2();
  List<String> dnsSearchOrder=cmd.getDnsSearchOrder();
  Boolean isPublic=cmd.isPublic();
  String allocationStateStr=cmd.getAllocationState();
  String dhcpProvider=cmd.getDhcpProvider();
  Map<?,?> detailsMap=cmd.getDetails();
  String networkDomain=cmd.getDomain();
  Map<String,String> newDetails=new HashMap<String,String>();
  if (detailsMap != null) {
    Collection<?> zoneDetailsCollection=detailsMap.values();
    Iterator<?> iter=zoneDetailsCollection.iterator();
    while (iter.hasNext()) {
      HashMap<?,?> detail=(HashMap<?,?>)iter.next();
      String key=(String)detail.get("String_Node_Str");
      String value=(String)detail.get("String_Node_Str");
      if ((key == null) || (value == null)) {
        throw new InvalidParameterValueException("String_Node_Str");
      }
      newDetails.put(key,value);
    }
  }
  if (dnsSearchOrder != null) {
    for (    String dom : dnsSearchOrder) {
      if (!NetUtils.verifyDomainName(dom)) {
        throw new InvalidParameterValueException("String_Node_Str" + "String_Node_Str");
      }
    }
    newDetails.put(ZoneConfig.DnsSearchOrder.getName(),StringUtils.join(dnsSearchOrder,"String_Node_Str"));
  }
  DataCenterVO zone=_zoneDao.findById(zoneId);
  if (zone == null) {
    throw new InvalidParameterValueException("String_Node_Str" + zoneId);
  }
  if (zoneName == null) {
    zoneName=zone.getName();
  }
  if (!validZone(zoneId)) {
    throw new InvalidParameterValueException("String_Node_Str" + zoneId + "String_Node_Str");
  }
  String oldZoneName=zone.getName();
  if (zoneName == null) {
    zoneName=oldZoneName;
  }
  if (dns1 == null) {
    dns1=zone.getDns1();
  }
  if (dns2 == null) {
    dns2=zone.getDns2();
  }
  if (internalDns1 == null) {
    internalDns1=zone.getInternalDns1();
  }
  if (networkDomain != null && !networkDomain.isEmpty()) {
    if (!NetUtils.verifyDomainName(networkDomain)) {
      throw new InvalidParameterValueException("String_Node_Str" + "String_Node_Str");
    }
  }
  boolean checkForDuplicates=!zoneName.equals(oldZoneName);
  checkZoneParameters(zoneName,dns1,dns2,internalDns1,internalDns2,checkForDuplicates,null,allocationStateStr);
  zone.setName(zoneName);
  zone.setDns1(dns1);
  zone.setDns2(dns2);
  zone.setInternalDns1(internalDns1);
  zone.setInternalDns2(internalDns2);
  if (networkDomain != null) {
    if (networkDomain.isEmpty()) {
      zone.setDomain(null);
    }
 else {
      zone.setDomain(networkDomain);
    }
  }
  if (isPublic != null && isPublic) {
    zone.setDomainId(null);
    zone.setDomain(null);
  }
  Transaction txn=Transaction.currentTxn();
  txn.start();
  Map<String,String> updatedDetails=new HashMap<String,String>();
  _zoneDao.loadDetails(zone);
  if (zone.getDetails() != null) {
    updatedDetails.putAll(zone.getDetails());
  }
  updatedDetails.putAll(newDetails);
  zone.setDetails(updatedDetails);
  if (allocationStateStr != null && !allocationStateStr.isEmpty()) {
    Grouping.AllocationState allocationState=Grouping.AllocationState.valueOf(allocationStateStr);
    zone.setAllocationState(allocationState);
  }
  if (dhcpProvider != null) {
    zone.setDhcpProvider(dhcpProvider);
  }
  if (!_zoneDao.update(zoneId,zone)) {
    throw new CloudRuntimeException("String_Node_Str");
  }
  txn.commit();
  return zone;
}