Program: 106608
Project: 106608
Buggy source:
@Override public AccountVO updateAccount(UpdateAccountCmd cmd){
  Long accountId=cmd.getId();
  Long domainId=cmd.getDomainId();
  String accountName=cmd.getAccountName();
  String newAccountName=cmd.getNewName();
  String networkDomain=cmd.getNetworkDomain();
  Map<String,String> details=cmd.getDetails();
  boolean success=false;
  Account account=null;
  if (accountId != null) {
    account=_accountDao.findById(accountId);
  }
 else {
    account=_accountDao.findEnabledAccount(accountName,domainId);
  }
  if (account == null || account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
    s_logger.error("String_Node_Str" + accountId + "String_Node_Str"+ accountName+ "String_Node_Str"+ domainId);
    throw new InvalidParameterValueException("String_Node_Str" + accountId + "String_Node_Str"+ accountName+ "String_Node_Str"+ domainId);
  }
  if (account.getId() == Account.ACCOUNT_ID_SYSTEM) {
    throw new InvalidParameterValueException("String_Node_Str");
  }
  checkAccess(UserContext.current().getCaller(),_domainMgr.getDomain(account.getDomainId()));
  Account duplicateAcccount=_accountDao.findActiveAccount(newAccountName,domainId);
  if (duplicateAcccount != null && duplicateAcccount.getId() != account.getId()) {
    throw new InvalidParameterValueException("String_Node_Str" + newAccountName + "String_Node_Str"+ domainId+ "String_Node_Str"+ duplicateAcccount.getId());
  }
  if (networkDomain != null) {
    if (!NetUtils.verifyDomainName(networkDomain)) {
      throw new InvalidParameterValueException("String_Node_Str" + "String_Node_Str");
    }
  }
  AccountVO acctForUpdate=_accountDao.findById(account.getId());
  acctForUpdate.setAccountName(newAccountName);
  if (networkDomain != null) {
    acctForUpdate.setNetworkDomain(networkDomain);
  }
  success=_accountDao.update(account.getId(),acctForUpdate);
  if (details != null) {
    _accountDetailsDao.update(account.getId(),details);
  }
  if (success) {
    return _accountDao.findById(account.getId());
  }
 else {
    throw new CloudRuntimeException("String_Node_Str" + accountId + "String_Node_Str"+ accountName+ "String_Node_Str"+ domainId);
  }
}

Fixed version (ground truth):
@Override @DB public AccountVO updateAccount(UpdateAccountCmd cmd){
  Long accountId=cmd.getId();
  Long domainId=cmd.getDomainId();
  String accountName=cmd.getAccountName();
  String newAccountName=cmd.getNewName();
  String networkDomain=cmd.getNetworkDomain();
  Map<String,String> details=cmd.getDetails();
  boolean success=false;
  Account account=null;
  if (accountId != null) {
    account=_accountDao.findById(accountId);
  }
 else {
    account=_accountDao.findEnabledAccount(accountName,domainId);
  }
  if (account == null || account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
    s_logger.error("String_Node_Str" + accountId + "String_Node_Str"+ accountName+ "String_Node_Str"+ domainId);
    throw new InvalidParameterValueException("String_Node_Str" + accountId + "String_Node_Str"+ accountName+ "String_Node_Str"+ domainId);
  }
  if (account.getId() == Account.ACCOUNT_ID_SYSTEM) {
    throw new InvalidParameterValueException("String_Node_Str");
  }
  checkAccess(UserContext.current().getCaller(),_domainMgr.getDomain(account.getDomainId()));
  Account duplicateAcccount=_accountDao.findActiveAccount(newAccountName,domainId);
  if (duplicateAcccount != null && duplicateAcccount.getId() != account.getId()) {
    throw new InvalidParameterValueException("String_Node_Str" + newAccountName + "String_Node_Str"+ domainId+ "String_Node_Str"+ duplicateAcccount.getId());
  }
  if (networkDomain != null && !networkDomain.isEmpty()) {
    if (!NetUtils.verifyDomainName(networkDomain)) {
      throw new InvalidParameterValueException("String_Node_Str" + "String_Node_Str");
    }
  }
  AccountVO acctForUpdate=_accountDao.findById(account.getId());
  acctForUpdate.setAccountName(newAccountName);
  if (networkDomain != null) {
    if (networkDomain.isEmpty()) {
      acctForUpdate.setNetworkDomain(null);
    }
 else {
      acctForUpdate.setNetworkDomain(networkDomain);
    }
  }
  Transaction txn=Transaction.currentTxn();
  txn.start();
  success=_accountDao.update(account.getId(),acctForUpdate);
  if (details != null && success) {
    _accountDetailsDao.update(account.getId(),details);
  }
  txn.commit();
  if (success) {
    return _accountDao.findById(account.getId());
  }
 else {
    throw new CloudRuntimeException("String_Node_Str" + accountId + "String_Node_Str"+ accountName+ "String_Node_Str"+ domainId);
  }
}