Skip to content

Commit 03ba659

Browse files
dgrizzantimurali-reddy
authored andcommitted
CLOUDSTACK-5022: NullPointerException when invalid zone is passed into UsageEventUtils
1 parent cf1eaad commit 03ba659

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,17 @@ private static void publishUsageEvent(String usageEventType, Long accountId, Lon
139139
if (account == null)
140140
return;
141141

142+
// if an invalid zone is passed in, create event without zone UUID
143+
String zoneUuid = null;
144+
if (dc != null)
145+
zoneUuid = dc.getUuid();
146+
142147
Event event = new Event(ManagementServer.Name, EventCategory.USAGE_EVENT.getName(), usageEventType,
143148
resourceType, resourceUUID);
144149

145150
Map<String, String> eventDescription = new HashMap<String, String>();
146151
eventDescription.put("account", account.getUuid());
147-
eventDescription.put("zone", dc.getUuid());
152+
eventDescription.put("zone", zoneUuid);
148153
eventDescription.put("event", usageEventType);
149154
eventDescription.put("resource", resourceType);
150155
eventDescription.put("id", resourceUUID);

0 commit comments

Comments
 (0)