Updated Branches: refs/heads/4.2 2005aae7a -> bbff5e84c
CLOUDSTACK-3422 - fix null pointer in usage and action events when deleting resources whose account has been removed Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/bbff5e84 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/bbff5e84 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/bbff5e84 Branch: refs/heads/4.2 Commit: bbff5e84ce00c7a40a04c0aedb7cfb7b75f0cae4 Parents: 2005aae Author: Marcus Sorensen <[email protected]> Authored: Tue Jul 9 09:37:23 2013 -0600 Committer: Marcus Sorensen <[email protected]> Committed: Tue Jul 9 09:44:54 2013 -0600 ---------------------------------------------------------------------- server/src/com/cloud/event/ActionEventUtils.java | 5 +++++ server/src/com/cloud/event/UsageEventUtils.java | 4 ++++ 2 files changed, 9 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bbff5e84/server/src/com/cloud/event/ActionEventUtils.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/event/ActionEventUtils.java b/server/src/com/cloud/event/ActionEventUtils.java index a2d4906..eb3efed 100755 --- a/server/src/com/cloud/event/ActionEventUtils.java +++ b/server/src/com/cloud/event/ActionEventUtils.java @@ -161,6 +161,11 @@ public class ActionEventUtils { Map<String, String> eventDescription = new HashMap<String, String>(); Account account = _accountDao.findById(accountId); User user = _userDao.findById(userId); + // if account has been deleted, this might be called during cleanup of resources and results in null pointer + if (account == null) + return; + if (user == null) + return; eventDescription.put("user", user.getUuid()); eventDescription.put("account", account.getUuid()); eventDescription.put("event", eventType); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bbff5e84/server/src/com/cloud/event/UsageEventUtils.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/event/UsageEventUtils.java b/server/src/com/cloud/event/UsageEventUtils.java index 5401244..2d92fae 100644 --- a/server/src/com/cloud/event/UsageEventUtils.java +++ b/server/src/com/cloud/event/UsageEventUtils.java @@ -124,6 +124,10 @@ public class UsageEventUtils { Account account = _accountDao.findById(accountId); DataCenterVO dc = _dcDao.findById(zoneId); + // if account has been deleted, this might be called during cleanup of resources and results in null pointer + if (account == null) + return; + Event event = new Event(ManagementServer.Name, EventCategory.USAGE_EVENT.getName(), usageEventType, resourceType, resourceUUID);
