Skip to content

Commit bbff5e8

Browse files
author
Marcus Sorensen
committed
CLOUDSTACK-3422 - fix null pointer in usage and action events when
deleting resources whose account has been removed
1 parent 2005aae commit bbff5e8

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

‎server/src/com/cloud/event/ActionEventUtils.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,11 @@ private static void publishOnEventBus(long userId, long accountId, String eventC
161161
Map<String, String> eventDescription = new HashMap<String, String>();
162162
Account account = _accountDao.findById(accountId);
163163
User user = _userDao.findById(userId);
164+
// if account has been deleted, this might be called during cleanup of resources and results in null pointer
165+
if (account == null)
166+
return;
167+
if (user == null)
168+
return;
164169
eventDescription.put("user", user.getUuid());
165170
eventDescription.put("account", account.getUuid());
166171
eventDescription.put("event", eventType);

‎server/src/com/cloud/event/UsageEventUtils.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ private static void publishUsageEvent(String usageEventType, Long accountId, Lon
124124
Account account = _accountDao.findById(accountId);
125125
DataCenterVO dc = _dcDao.findById(zoneId);
126126

127+
// if account has been deleted, this might be called during cleanup of resources and results in null pointer
128+
if (account == null)
129+
return;
130+
127131
Event event = new Event(ManagementServer.Name, EventCategory.USAGE_EVENT.getName(), usageEventType,
128132
resourceType, resourceUUID);
129133

0 commit comments

Comments
 (0)