cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [2/2] git commit: updated refs/heads/4.3 to 514c2ef
Date Mon, 01 Sep 2014 14:15:36 GMT
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 <rohit.yadav@shapeblue.com>
(cherry picked from commit 7ada4ad50b683268f4031ff05e9d19d15d2c35f1)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

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 <rohit.yadav@shapeblue.com>
Authored: Thu Aug 21 11:35:38 2014 +0200
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
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;
         }
     }
 


Mime
View raw message