CLOUDSTACK-3422 - fix null pointer in usage and action events when

deleting resources whose account has been removed
This commit is contained in:
Marcus Sorensen 2013-07-09 09:37:23 -06:00
parent 2005aae7ac
commit bbff5e84ce
2 changed files with 9 additions and 0 deletions

View File

@ -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);

View File

@ -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);