Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id B3521200C29 for ; Tue, 28 Feb 2017 23:57:11 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id B20E0160B7E; Tue, 28 Feb 2017 22:57:11 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 10E39160B59 for ; Tue, 28 Feb 2017 23:57:10 +0100 (CET) Received: (qmail 27418 invoked by uid 500); 28 Feb 2017 22:57:10 -0000 Mailing-List: contact commits-help@brooklyn.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@brooklyn.apache.org Delivered-To: mailing list commits@brooklyn.apache.org Received: (qmail 27405 invoked by uid 99); 28 Feb 2017 22:57:10 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Feb 2017 22:57:10 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 23615DFF09; Tue, 28 Feb 2017 22:57:10 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aledsage@apache.org To: commits@brooklyn.apache.org Date: Tue, 28 Feb 2017 22:57:10 -0000 Message-Id: <3d910ee1267f4c9396f1a0283922597e@git.apache.org> X-Mailer: ASF-Git Admin Mailer 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 archived-at: Tue, 28 Feb 2017 22:57:11 -0000 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 Authored: Tue Feb 28 12:57:12 2017 +0000 Committer: Alex Heneveld 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(); }