ConfigurationManagerImpl: Fix NPE when trying to access method on null object

Before checking obj.length, the fix is to check that the obj is not null

Signed-off-by: Rohit Yadav <rohit.ya...@shapeblue.com>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/e3b3a18a
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/e3b3a18a
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/e3b3a18a

Branch: refs/heads/saml2
Commit: e3b3a18aefb8364543cb162a289dabd3ff8293a5
Parents: 4a6560a
Author: Rohit Yadav <rohit.ya...@shapeblue.com>
Authored: Thu Aug 21 11:34:44 2014 +0200
Committer: Rohit Yadav <rohit.ya...@shapeblue.com>
Committed: Thu Aug 21 11:34:44 2014 +0200

----------------------------------------------------------------------
 server/src/com/cloud/configuration/ConfigurationManagerImpl.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e3b3a18a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java 
b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index bcd87da..bfa79a2 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -407,7 +407,7 @@ public class ConfigurationManagerImpl extends ManagerBase 
implements Configurati
         String mgtCidr = _configDao.getValue(Config.ManagementNetwork.key());
         if (mgtCidr == null || mgtCidr.trim().isEmpty()) {
             String[] localCidrs = NetUtils.getLocalCidrs();
-            if (localCidrs.length > 0) {
+            if (localCidrs != null && (localCidrs.length > 0)) {
                 s_logger.warn("Management network CIDR is not configured 
originally. Set it default to " + localCidrs[0]);
 
                 
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_MANAGMENT_NODE, 0, new 
Long(0), "Management network CIDR is not configured originally. Set it default 
to "

Reply via email to