Program: 89869
Project: 89869
Buggy source:
@Override 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();
  String vnetRange=cmd.getVlan();
  String guestCidr=cmd.getGuestCidrAddress();
  Long userId=UserContext.current().getCallerUserId();
  if (userId == null) {
    userId=Long.valueOf(User.UID_SYSTEM);
  }
  DataCenterVO zone=_zoneDao.findById(zoneId);
  if (zone == null) {
    throw new ServerApiException(BaseCmd.PARAM_ERROR,"String_Node_Str" + zoneId);
  }
  if (zoneName == null) {
    zoneName=zone.getName();
  }
  if (vnetRange != null && zone.getNetworkType() == NetworkType.Basic) {
    throw new InvalidParameterValueException("String_Node_Str");
  }
  if (!validZone(zoneId)) {
    throw new InvalidParameterValueException("String_Node_Str" + zoneId + "String_Node_Str");
  }
  if (vnetRange != null) {
    if (zoneHasAllocatedVnets(zoneId)) {
      throw new CloudRuntimeException("String_Node_Str");
    }
  }
  String oldZoneName=zone.getName();
  if (zoneName == null) {
    zoneName=oldZoneName;
  }
  boolean dnsUpdate=false;
  if (dns1 != null || dns2 != null) {
    dnsUpdate=true;
  }
  if (dns1 == null) {
    dns1=zone.getDns1();
  }
  if (dns2 == null) {
    dns2=zone.getDns2();
  }
  if (internalDns1 == null) {
    internalDns1=zone.getInternalDns1();
  }
  if (guestCidr == null) {
    guestCidr=zone.getGuestNetworkCidr();
  }
  boolean checkForDuplicates=!zoneName.equals(oldZoneName);
  checkZoneParameters(zoneName,dns1,dns2,internalDns1,internalDns2,checkForDuplicates,null);
  zone.setName(zoneName);
  zone.setDns1(dns1);
  zone.setDns2(dns2);
  zone.setInternalDns1(internalDns1);
  zone.setInternalDns2(internalDns2);
  zone.setGuestNetworkCidr(guestCidr);
  if (vnetRange != null) {
    zone.setVnet(vnetRange);
  }
  if (!_zoneDao.update(zoneId,zone)) {
    throw new CloudRuntimeException("String_Node_Str");
  }
  if (vnetRange != null) {
    String[] tokens=vnetRange.split("String_Node_Str");
    int begin=Integer.parseInt(tokens[0]);
    int end=tokens.length == 1 ? (begin) : Integer.parseInt(tokens[1]);
    _zoneDao.deleteVnet(zoneId);
    _zoneDao.addVnet(zone.getId(),begin,end);
  }
  if (dnsUpdate) {
    List<DomainRouterVO> DomainRouters=_domrDao.listByDataCenter(zoneId);
    for (    DomainRouterVO domR : DomainRouters) {
      domR.setDns1(dns1);
      domR.setDns2(dns2);
      _domrDao.update(domR.getId(),domR);
    }
    List<VMInstanceVO> ConsoleProxies=_vmInstanceDao.listByZoneIdAndType(zoneId,VirtualMachine.Type.ConsoleProxy);
    for (    VMInstanceVO consoleVm : ConsoleProxies) {
      ConsoleProxyVO proxy=_consoleDao.findById(consoleVm.getId());
      if (proxy != null) {
        proxy.setDns1(dns1);
        proxy.setDns2(dns2);
        _consoleDao.update(proxy.getId(),proxy);
      }
    }
    List<VMInstanceVO> storageVms=_vmInstanceDao.listByZoneIdAndType(zoneId,VirtualMachine.Type.SecondaryStorageVm);
    for (    VMInstanceVO storageVm : storageVms) {
      SecondaryStorageVmVO secStorageVm=_secStorageDao.findById(storageVm.getId());
      if (secStorageVm != null) {
        secStorageVm.setDns1(dns1);
        secStorageVm.setDns2(dns2);
        _secStorageDao.update(secStorageVm.getId(),secStorageVm);
      }
    }
  }
  saveConfigurationEvent(userId,null,EventTypes.EVENT_ZONE_EDIT,"String_Node_Str" + zone.getName() + "String_Node_Str","String_Node_Str" + zone.getId(),"String_Node_Str" + dns1,"String_Node_Str" + dns2,"String_Node_Str" + internalDns1,"String_Node_Str" + internalDns2,"String_Node_Str" + vnetRange,"String_Node_Str" + guestCidr);
  return zone;
}

Fixed version (ground truth):
@Override 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();
  String vnetRange=cmd.getVlan();
  String guestCidr=cmd.getGuestCidrAddress();
  Long userId=UserContext.current().getCallerUserId();
  int startVnetRange=0;
  int stopVnetRange=0;
  if (userId == null) {
    userId=Long.valueOf(User.UID_SYSTEM);
  }
  DataCenterVO zone=_zoneDao.findById(zoneId);
  if (zone == null) {
    throw new ServerApiException(BaseCmd.PARAM_ERROR,"String_Node_Str" + zoneId);
  }
  if (zoneName == null) {
    zoneName=zone.getName();
  }
  if (vnetRange != null && zone.getNetworkType() == NetworkType.Basic) {
    throw new InvalidParameterValueException("String_Node_Str");
  }
  if (!validZone(zoneId)) {
    throw new InvalidParameterValueException("String_Node_Str" + zoneId + "String_Node_Str");
  }
  if (vnetRange != null) {
    if (zoneHasAllocatedVnets(zoneId)) {
      throw new CloudRuntimeException("String_Node_Str");
    }
    String[] startStopRange=new String[2];
    startStopRange=vnetRange.split("String_Node_Str");
    if (startStopRange.length == 1) {
      throw new InvalidParameterValueException("String_Node_Str");
    }
    if (startStopRange[0] == null || startStopRange[1] == null) {
      throw new InvalidParameterValueException("String_Node_Str");
    }
    try {
      startVnetRange=Integer.parseInt(startStopRange[0]);
      stopVnetRange=Integer.parseInt(startStopRange[1]);
    }
 catch (    NumberFormatException e) {
      s_logger.warn("String_Node_Str",e);
      throw new InvalidParameterValueException("String_Node_Str");
    }
    if (startVnetRange < 0 || stopVnetRange > 4096) {
      throw new InvalidParameterValueException("String_Node_Str");
    }
    if (startVnetRange > stopVnetRange) {
      throw new InvalidParameterValueException("String_Node_Str");
    }
  }
  String oldZoneName=zone.getName();
  if (zoneName == null) {
    zoneName=oldZoneName;
  }
  boolean dnsUpdate=false;
  if (dns1 != null || dns2 != null) {
    dnsUpdate=true;
  }
  if (dns1 == null) {
    dns1=zone.getDns1();
  }
  if (dns2 == null) {
    dns2=zone.getDns2();
  }
  if (internalDns1 == null) {
    internalDns1=zone.getInternalDns1();
  }
  if (guestCidr == null) {
    guestCidr=zone.getGuestNetworkCidr();
  }
  boolean checkForDuplicates=!zoneName.equals(oldZoneName);
  checkZoneParameters(zoneName,dns1,dns2,internalDns1,internalDns2,checkForDuplicates,null);
  zone.setName(zoneName);
  zone.setDns1(dns1);
  zone.setDns2(dns2);
  zone.setInternalDns1(internalDns1);
  zone.setInternalDns2(internalDns2);
  zone.setGuestNetworkCidr(guestCidr);
  if (vnetRange != null) {
    zone.setVnet(vnetRange);
  }
  if (!_zoneDao.update(zoneId,zone)) {
    throw new CloudRuntimeException("String_Node_Str");
  }
  if (vnetRange != null) {
    String[] tokens=vnetRange.split("String_Node_Str");
    int begin=Integer.parseInt(tokens[0]);
    int end=tokens.length == 1 ? (begin) : Integer.parseInt(tokens[1]);
    _zoneDao.deleteVnet(zoneId);
    _zoneDao.addVnet(zone.getId(),begin,end);
  }
  if (dnsUpdate) {
    List<DomainRouterVO> DomainRouters=_domrDao.listByDataCenter(zoneId);
    for (    DomainRouterVO domR : DomainRouters) {
      domR.setDns1(dns1);
      domR.setDns2(dns2);
      _domrDao.update(domR.getId(),domR);
    }
    List<VMInstanceVO> ConsoleProxies=_vmInstanceDao.listByZoneIdAndType(zoneId,VirtualMachine.Type.ConsoleProxy);
    for (    VMInstanceVO consoleVm : ConsoleProxies) {
      ConsoleProxyVO proxy=_consoleDao.findById(consoleVm.getId());
      if (proxy != null) {
        proxy.setDns1(dns1);
        proxy.setDns2(dns2);
        _consoleDao.update(proxy.getId(),proxy);
      }
    }
    List<VMInstanceVO> storageVms=_vmInstanceDao.listByZoneIdAndType(zoneId,VirtualMachine.Type.SecondaryStorageVm);
    for (    VMInstanceVO storageVm : storageVms) {
      SecondaryStorageVmVO secStorageVm=_secStorageDao.findById(storageVm.getId());
      if (secStorageVm != null) {
        secStorageVm.setDns1(dns1);
        secStorageVm.setDns2(dns2);
        _secStorageDao.update(secStorageVm.getId(),secStorageVm);
      }
    }
  }
  saveConfigurationEvent(userId,null,EventTypes.EVENT_ZONE_EDIT,"String_Node_Str" + zone.getName() + "String_Node_Str","String_Node_Str" + zone.getId(),"String_Node_Str" + dns1,"String_Node_Str" + dns2,"String_Node_Str" + internalDns1,"String_Node_Str" + internalDns2,"String_Node_Str" + vnetRange,"String_Node_Str" + guestCidr);
  return zone;
}