Program: 89228
Project: 89228
Buggy source:
@Override @ActionEvent(eventType=EventTypes.EVENT_DOMAIN_UPDATE,eventDescription="String_Node_Str") @DB public DomainVO updateDomain(UpdateDomainCmd cmd){
  Long domainId=cmd.getId();
  String domainName=cmd.getDomainName();
  String networkDomain=cmd.getNetworkDomain();
  DomainVO domain=_domainDao.findById(domainId);
  if (domain == null) {
    throw new InvalidParameterValueException("String_Node_Str" + domainId);
  }
 else   if (domain.getParent() == null && domainName != null) {
    throw new InvalidParameterValueException("String_Node_Str");
  }
  Account caller=UserContext.current().getCaller();
  _accountMgr.checkAccess(caller,domain);
  if (domainName != null) {
    SearchCriteria<DomainVO> sc=_domainDao.createSearchCriteria();
    sc.addAnd("String_Node_Str",SearchCriteria.Op.EQ,domainName);
    List<DomainVO> domains=_domainDao.search(sc,null);
    if (!domains.isEmpty()) {
      throw new InvalidParameterValueException("String_Node_Str" + domainId + "String_Node_Str"+ domainName+ "String_Node_Str");
    }
  }
  if (networkDomain != null) {
    if (!NetUtils.verifyDomainName(networkDomain)) {
      throw new InvalidParameterValueException("String_Node_Str" + "String_Node_Str");
    }
  }
  Transaction txn=Transaction.currentTxn();
  txn.start();
  if (domainName != null) {
    String updatedDomainPath=getUpdatedDomainPath(domain.getPath(),domainName);
    updateDomainChildren(domain,updatedDomainPath);
    domain.setName(domainName);
    domain.setPath(updatedDomainPath);
  }
  if (networkDomain != null) {
    domain.setNetworkDomain(networkDomain);
  }
  _domainDao.update(domainId,domain);
  txn.commit();
  return _domainDao.findById(domainId);
}

Fixed version (ground truth):
@Override @ActionEvent(eventType=EventTypes.EVENT_DOMAIN_UPDATE,eventDescription="String_Node_Str") @DB public DomainVO updateDomain(UpdateDomainCmd cmd){
  Long domainId=cmd.getId();
  String domainName=cmd.getDomainName();
  String networkDomain=cmd.getNetworkDomain();
  DomainVO domain=_domainDao.findById(domainId);
  if (domain == null) {
    throw new InvalidParameterValueException("String_Node_Str" + domainId);
  }
 else   if (domain.getParent() == null && domainName != null) {
    throw new InvalidParameterValueException("String_Node_Str");
  }
  Account caller=UserContext.current().getCaller();
  _accountMgr.checkAccess(caller,domain);
  if (domainName != null) {
    SearchCriteria<DomainVO> sc=_domainDao.createSearchCriteria();
    sc.addAnd("String_Node_Str",SearchCriteria.Op.EQ,domainName);
    List<DomainVO> domains=_domainDao.search(sc,null);
    boolean sameDomain=(domains.size() == 1 && domains.get(0).getId() == domainId);
    if (!domains.isEmpty() && !sameDomain) {
      throw new InvalidParameterValueException("String_Node_Str" + domainId + "String_Node_Str"+ domainName+ "String_Node_Str");
    }
  }
  if (networkDomain != null && !networkDomain.isEmpty()) {
    if (!NetUtils.verifyDomainName(networkDomain)) {
      throw new InvalidParameterValueException("String_Node_Str" + "String_Node_Str");
    }
  }
  Transaction txn=Transaction.currentTxn();
  txn.start();
  if (domainName != null) {
    String updatedDomainPath=getUpdatedDomainPath(domain.getPath(),domainName);
    updateDomainChildren(domain,updatedDomainPath);
    domain.setName(domainName);
    domain.setPath(updatedDomainPath);
  }
  if (networkDomain != null) {
    if (networkDomain.isEmpty()) {
      domain.setNetworkDomain(null);
    }
 else {
      domain.setNetworkDomain(networkDomain);
    }
  }
  _domainDao.update(domainId,domain);
  txn.commit();
  return _domainDao.findById(domainId);
}