stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From im...@apache.org
Subject stratos git commit: Adding null check to avoid NPE in cluster monitor
Date Fri, 26 Dec 2014 12:40:33 GMT
Repository: stratos
Updated Branches:
  refs/heads/master d41193cb7 -> 9cd4e89b1


Adding null check to avoid NPE in cluster monitor


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

Branch: refs/heads/master
Commit: 9cd4e89b14fcc528ee117c1a037ee2a281ca67bf
Parents: d41193c
Author: Imesh Gunaratne <imesh@apache.org>
Authored: Fri Dec 26 18:10:23 2014 +0530
Committer: Imesh Gunaratne <imesh@apache.org>
Committed: Fri Dec 26 18:10:23 2014 +0530

----------------------------------------------------------------------
 .../autoscaler/monitor/cluster/ClusterMonitor.java       | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/9cd4e89b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
index f9ac6f0..251ac46 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
@@ -19,6 +19,7 @@
 package org.apache.stratos.autoscaler.monitor.cluster;
 
 import org.apache.commons.configuration.XMLConfiguration;
+import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.client.CloudControllerClient;
@@ -1108,11 +1109,17 @@ public class ClusterMonitor extends AbstractClusterMonitor {
         return ((ClusterContext) this.clusterContext).getNetworkPartitionCtxts();
     }
 
-    public ClusterInstanceContext getClusterInstanceContext(String networkPartitionId, String
instanceId) {
-        Map<String, ClusterLevelNetworkPartitionContext> clusterLevelNetworkPartitionContextMap
=
+    public ClusterInstanceContext getClusterInstanceContext(String networkPartitionId, String
instanceId) {Map<String, ClusterLevelNetworkPartitionContext> clusterLevelNetworkPartitionContextMap
=
                 ((ClusterContext) this.clusterContext).getNetworkPartitionCtxts();
+        if(StringUtils.isBlank(networkPartitionId)) {
+            throw new RuntimeException("Network partition id is null");
+        }
         ClusterLevelNetworkPartitionContext networkPartitionContext =
                 clusterLevelNetworkPartitionContextMap.get(networkPartitionId);
+        if(networkPartitionContext == null) {
+            throw new RuntimeException("Network partition context not found: [network-partition-id]
" +
+            networkPartitionId);
+        }
         ClusterInstanceContext instanceContext = (ClusterInstanceContext) networkPartitionContext.
                                                         getInstanceContext(instanceId);
         return instanceContext;


Mime
View raw message