From 901f52eb99ea82effc8b50e6db8528ed42424681 Mon Sep 17 00:00:00 2001 From: Kris McQueen Date: Wed, 27 Oct 2010 17:16:28 -0700 Subject: [PATCH] bug 6782: incremental checkin for deleting an account. Since there was a change to findById to not find removed objects, these NPEs pop up from time to time where we expected to find the object previously and now it's not found. Since the account is getting deleted, do a findByIdIncludingRemoved to make sure the actual account object is retrieved. --- server/src/com/cloud/server/ManagementServerImpl.java | 2 +- server/src/com/cloud/user/AccountManagerImpl.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index a454904c77d..b346e2fa274 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -821,7 +821,7 @@ public class ManagementServerImpl implements ManagementServer { s_logger.debug("Remove account " + accountId); } - AccountVO account = _accountDao.findById(accountId); + AccountVO account = _accountDao.findByIdIncludingRemoved(accountId); deleteAccount(account); EventUtils.saveEvent(Long.valueOf(1), Long.valueOf(1), EventVO.LEVEL_INFO, EventTypes.EVENT_USER_DELETE, "User " + username + " (id: " + userId + ") for accountId = " + accountId + " and domainId = " + userAccount.getDomainId() + " was deleted."); diff --git a/server/src/com/cloud/user/AccountManagerImpl.java b/server/src/com/cloud/user/AccountManagerImpl.java index e589b3bd2ce..05b2f75e68e 100644 --- a/server/src/com/cloud/user/AccountManagerImpl.java +++ b/server/src/com/cloud/user/AccountManagerImpl.java @@ -125,7 +125,7 @@ public class AccountManagerImpl implements AccountManager { // on a per-domain basis, decrement the count // FIXME: can this decrement be done on the database side in a custom update statement? - Account account = _accountDao.findById(accountId); + Account account = _accountDao.findByIdIncludingRemoved(accountId); // find all accounts, even removed accounts if this happens to be for an account that's being deleted Long domainId = account.getDomainId(); while (domainId != null) { _resourceCountDao.updateDomainCount(domainId, type, false, numToDecrement);