JmxSupport: improve NPE message when jmxPort null Was previously throwing NPE converting the null attribute value to an `int`.
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/cda838a4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/cda838a4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/cda838a4 Branch: refs/heads/master Commit: cda838a41265ef45eebd1854ac688bef979a4c96 Parents: 2655dca Author: Aled Sage <[email protected]> Authored: Mon Jun 22 00:16:53 2015 +0100 Committer: Aled Sage <[email protected]> Committed: Mon Jun 22 00:16:53 2015 +0100 ---------------------------------------------------------------------- software/base/src/main/java/brooklyn/entity/java/JmxSupport.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/cda838a4/software/base/src/main/java/brooklyn/entity/java/JmxSupport.java ---------------------------------------------------------------------- diff --git a/software/base/src/main/java/brooklyn/entity/java/JmxSupport.java b/software/base/src/main/java/brooklyn/entity/java/JmxSupport.java index a6133a9..f10cf8d 100644 --- a/software/base/src/main/java/brooklyn/entity/java/JmxSupport.java +++ b/software/base/src/main/java/brooklyn/entity/java/JmxSupport.java @@ -273,7 +273,8 @@ public class JmxSupport implements UsesJmx { public void applyJmxJavaSystemProperties(MutableMap.Builder<String,Object> result) { if (!isJmx()) return ; - HostAndPort jmx = BrooklynAccessUtils.getBrooklynAccessibleAddress(entity, entity.getAttribute(JMX_PORT)); + Integer jmxPort = Preconditions.checkNotNull(entity.getAttribute(JMX_PORT), "jmx port must not be null for %s", entity); + HostAndPort jmx = BrooklynAccessUtils.getBrooklynAccessibleAddress(entity, jmxPort); Integer jmxRemotePort = getEntity().getAttribute(JMX_PORT); String hostName = jmx.getHostText();
