From b4ef066846b6eb9d94204fb421ae9eccdbf914b8 Mon Sep 17 00:00:00 2001 From: Kris McQueen Date: Wed, 27 Oct 2010 18:23:18 -0700 Subject: [PATCH] bug 6782: fix NPEs associated with looking up the account after it's been deleted. When cleaning up the account, we delete the accountVO first, then stop/destroy VMs, routers, etc. During this cleanup, there are times when the account needs to be retrieved, and since it's been removed it has to be found by id 'including removed' in order to find it. status 6782: resolved fixed --- core/src/com/cloud/user/dao/AccountDaoImpl.java | 2 +- utils/src/com/cloud/utils/db/GenericDaoBase.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/com/cloud/user/dao/AccountDaoImpl.java b/core/src/com/cloud/user/dao/AccountDaoImpl.java index 1b60f22d2b4..5715ac58515 100644 --- a/core/src/com/cloud/user/dao/AccountDaoImpl.java +++ b/core/src/com/cloud/user/dao/AccountDaoImpl.java @@ -174,7 +174,7 @@ public class AccountDaoImpl extends GenericDaoBase implements A @Override public void markForCleanup(long accountId) { - AccountVO account = findById(accountId); + AccountVO account = findByIdIncludingRemoved(accountId); if (!account.getNeedsCleanup()) { account.setNeedsCleanup(true); update(accountId, account); diff --git a/utils/src/com/cloud/utils/db/GenericDaoBase.java b/utils/src/com/cloud/utils/db/GenericDaoBase.java index 53df12503e4..236d49980bb 100755 --- a/utils/src/com/cloud/utils/db/GenericDaoBase.java +++ b/utils/src/com/cloud/utils/db/GenericDaoBase.java @@ -1137,7 +1137,7 @@ public abstract class GenericDaoBase implements Gene } } - return _idField != null ? findById(id) : null; + return _idField != null ? findByIdIncludingRemoved(id) : null; } @DB(txn=false)