brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [1/2] brooklyn-server git commit: could get NPE if application was GC'd at same time as location, do not fail in that case
Date Tue, 28 Feb 2017 22:57:10 GMT
Repository: brooklyn-server
Updated Branches:
  refs/heads/master 442261741 -> 0b18b6cb9


could get NPE if application was GC'd at same time as location, do not fail in that case

we want to make sure a record is generated, even if it is incomplete


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/43a456f9
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/43a456f9
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/43a456f9

Branch: refs/heads/master
Commit: 43a456f97bf39faa409c88e431382c60a25ff724
Parents: 17aa622
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Tue Feb 28 12:57:12 2017 +0000
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Tue Feb 28 12:57:12 2017 +0000

----------------------------------------------------------------------
 .../org/apache/brooklyn/core/mgmt/usage/LocationUsage.java   | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/43a456f9/core/src/main/java/org/apache/brooklyn/core/mgmt/usage/LocationUsage.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/usage/LocationUsage.java b/core/src/main/java/org/apache/brooklyn/core/mgmt/usage/LocationUsage.java
index 7d4013f..aef2be2 100644
--- a/core/src/main/java/org/apache/brooklyn/core/mgmt/usage/LocationUsage.java
+++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/usage/LocationUsage.java
@@ -27,6 +27,7 @@ import java.util.Map;
 
 import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
 
+import com.google.common.base.MoreObjects;
 import com.google.common.base.Objects;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Lists;
@@ -52,7 +53,8 @@ public class LocationUsage {
             this.state = checkNotNull(state, "state");
             this.entityId = checkNotNull(entityId, "entityId");
             this.entityType = checkNotNull(entityType, "entityType");
-            this.applicationId = checkNotNull(applicationId, "applicationId (entity "+entityId+")");
+            // application ID can be null if hierarchy has been destroyed in parallel; better
to record the event than fail
+            this.applicationId = applicationId==null ? "" : applicationId;
             this.user = user;
         }
 
@@ -96,7 +98,7 @@ public class LocationUsage {
         
         @Override
         public String toString() {
-            return Objects.toStringHelper(this)
+            return MoreObjects.toStringHelper(this)
                     .add("date", date)
                     .add("state", state)
                     .add("entityId", entityId)
@@ -135,7 +137,7 @@ public class LocationUsage {
     
     @Override
     public String toString() {
-        return Objects.toStringHelper(this)
+        return MoreObjects.toStringHelper(this)
                 .add("locationId", locationId)
                 .toString();
     }


Mime
View raw message