Program: 107278
Project: 107278
Buggy source:
@Override public AccountVO updateAccount(UpdateAccountCmd cmd) throws InvalidParameterValueException, PermissionDeniedException {
  Long domainId=cmd.getDomainId();
  String accountName=cmd.getAccountName();
  String newAccountName=cmd.getNewName();
  boolean success=false;
  Account account=_accountDao.findAccount(accountName,domainId);
  if (account == null) {
    s_logger.error("String_Node_Str" + accountName + "String_Node_Str"+ domainId);
    throw new InvalidParameterValueException("String_Node_Str" + accountName + "String_Node_Str"+ domainId);
  }
  if (account.getId() == Account.ACCOUNT_ID_SYSTEM) {
    throw new InvalidParameterValueException("String_Node_Str");
  }
  Account adminAccount=UserContext.current().getAccount();
  if ((adminAccount != null) && (adminAccount.getType() != Account.ACCOUNT_TYPE_ADMIN) && _domainDao.isChildDomain(adminAccount.getDomainId(),account.getDomainId())) {
    throw new PermissionDeniedException("String_Node_Str" + accountName + "String_Node_Str"+ domainId+ "String_Node_Str");
  }
  Account duplicateAcccount=_accountDao.findAccount(newAccountName,domainId);
  if (duplicateAcccount != null && duplicateAcccount.getId() != account.getId()) {
    throw new PermissionDeniedException("String_Node_Str" + newAccountName + "String_Node_Str"+ domainId+ "String_Node_Str"+ duplicateAcccount.getId());
  }
  if (account.getAccountName().equals(newAccountName)) {
    success=true;
  }
 else {
    AccountVO acctForUpdate=_accountDao.createForUpdate();
    acctForUpdate.setAccountName(newAccountName);
    success=_accountDao.update(Long.valueOf(account.getId()),acctForUpdate);
  }
  if (success) {
    return _accountDao.findById(account.getId());
  }
 else {
    throw new CloudRuntimeException("String_Node_Str" + accountName + "String_Node_Str"+ domainId);
  }
}

Fixed version (ground truth):
@Override public AccountVO updateAccount(UpdateAccountCmd cmd) throws InvalidParameterValueException, PermissionDeniedException {
  Long domainId=cmd.getDomainId();
  String accountName=cmd.getAccountName();
  String newAccountName=cmd.getNewName();
  boolean success=false;
  Account account=_accountDao.findAccount(accountName,domainId);
  if (account == null) {
    s_logger.error("String_Node_Str" + accountName + "String_Node_Str"+ domainId);
    throw new InvalidParameterValueException("String_Node_Str" + accountName + "String_Node_Str"+ domainId);
  }
  if (account.getId() == Account.ACCOUNT_ID_SYSTEM) {
    throw new InvalidParameterValueException("String_Node_Str");
  }
  Account adminAccount=UserContext.current().getAccount();
  if ((adminAccount != null) && (adminAccount.getType() != Account.ACCOUNT_TYPE_ADMIN) && _domainDao.isChildDomain(adminAccount.getDomainId(),account.getDomainId())) {
    throw new PermissionDeniedException("String_Node_Str" + accountName + "String_Node_Str"+ domainId+ "String_Node_Str");
  }
  Account duplicateAcccount=_accountDao.findAccount(newAccountName,domainId);
  if (duplicateAcccount != null && duplicateAcccount.getRemoved() == null && duplicateAcccount.getId() != account.getId()) {
    throw new PermissionDeniedException("String_Node_Str" + newAccountName + "String_Node_Str"+ domainId+ "String_Node_Str"+ duplicateAcccount.getId());
  }
  if (account.getAccountName().equals(newAccountName)) {
    success=true;
  }
 else {
    AccountVO acctForUpdate=_accountDao.createForUpdate();
    acctForUpdate.setAccountName(newAccountName);
    success=_accountDao.update(Long.valueOf(account.getId()),acctForUpdate);
  }
  if (success) {
    return _accountDao.findById(account.getId());
  }
 else {
    throw new CloudRuntimeException("String_Node_Str" + accountName + "String_Node_Str"+ domainId);
  }
}