From 22422b9ddd3ea1566f66d971307235569bffb003 Mon Sep 17 00:00:00 2001 From: David Grizzanti Date: Tue, 3 Dec 2013 11:45:27 -0500 Subject: [PATCH] CLOUDSTACK-5022: NullPointerException when invalid zone is passed into UsageEventUtils --- .../src/com/cloud/event/UsageEventUtils.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/engine/components-api/src/com/cloud/event/UsageEventUtils.java b/engine/components-api/src/com/cloud/event/UsageEventUtils.java index e71afb015db..90a2f17f1b8 100644 --- a/engine/components-api/src/com/cloud/event/UsageEventUtils.java +++ b/engine/components-api/src/com/cloud/event/UsageEventUtils.java @@ -153,11 +153,16 @@ public class UsageEventUtils { if (account == null) return; + // if an invalid zone is passed in, create event without zone UUID + String zoneUuid = null; + if (dc != null) + zoneUuid = dc.getUuid(); + Event event = new Event(Name, EventCategory.USAGE_EVENT.getName(), usageEventType, resourceType, resourceUUID); Map eventDescription = new HashMap(); eventDescription.put("account", account.getUuid()); - eventDescription.put("zone", dc.getUuid()); + eventDescription.put("zone", zoneUuid); eventDescription.put("event", usageEventType); eventDescription.put("resource", resourceType); eventDescription.put("id", resourceUUID);