Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9849311021 for ; Mon, 1 Sep 2014 14:15:35 +0000 (UTC) Received: (qmail 90000 invoked by uid 500); 1 Sep 2014 14:15:35 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 89880 invoked by uid 500); 1 Sep 2014 14:15:35 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 89861 invoked by uid 99); 1 Sep 2014 14:15:35 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Sep 2014 14:15:35 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 11B8C9579AE; Mon, 1 Sep 2014 14:15:35 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: bhaisaab@apache.org To: commits@cloudstack.apache.org Date: Mon, 01 Sep 2014 14:15:36 -0000 Message-Id: <0f01aa86a08b4a67b322b1f16fd8e770@git.apache.org> In-Reply-To: <0d1b5847f3734eff9a7bd081d72af620@git.apache.org> References: <0d1b5847f3734eff9a7bd081d72af620@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/2] git commit: updated refs/heads/4.3 to 514c2ef NetUtils: Check for NPE in getDefaultHostIp method when processing nic/mac On hosts or containers where they don't have valid mac address on nic resulting in null, NetUtils.getNetworkParam can throw NPE. This was a case found on TravisCI where OpenVZ containers are used. This method (getDefaultHostIp) is used at several other places within the ACS codebase to get the host IP and if null is caught we fallback to localhost or 127.0.0.1, so we therefore set info to null before trying to process network param and if we fail we return null and expect other layers to use localhost. Signed-off-by: Rohit Yadav (cherry picked from commit 7ada4ad50b683268f4031ff05e9d19d15d2c35f1) Signed-off-by: Rohit Yadav Conflicts: utils/src/com/cloud/utils/net/NetUtils.java Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/514c2ef0 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/514c2ef0 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/514c2ef0 Branch: refs/heads/4.3 Commit: 514c2ef0fbeebb039bf294f793fdd8268791d910 Parents: 435fa22 Author: Rohit Yadav Authored: Thu Aug 21 11:35:38 2014 +0200 Committer: Rohit Yadav Committed: Mon Sep 1 16:09:36 2014 +0200 ---------------------------------------------------------------------- utils/src/com/cloud/utils/net/NetUtils.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/514c2ef0/utils/src/com/cloud/utils/net/NetUtils.java ---------------------------------------------------------------------- diff --git a/utils/src/com/cloud/utils/net/NetUtils.java b/utils/src/com/cloud/utils/net/NetUtils.java index 1c94b71..f7446b7 100755 --- a/utils/src/com/cloud/utils/net/NetUtils.java +++ b/utils/src/com/cloud/utils/net/NetUtils.java @@ -195,8 +195,16 @@ public class NetUtils { return null; } - String[] info = NetUtils.getNetworkParams(nic); - return info[0]; + String[] info = null; + try { + info = NetUtils.getNetworkParams(nic); + } catch (NullPointerException ignored) { + s_logger.debug("Caught NullPointerException when trying to getDefaultHostIp"); + } + if (info != null) { + return info[0]; + } + return null; } }