You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by re...@apache.org on 2014/03/04 05:29:17 UTC

git commit: fixing NPE while listing policies

Repository: incubator-stratos
Updated Branches:
  refs/heads/master 7fb24d00e -> 1f615a1b0


fixing NPE while listing policies


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

Branch: refs/heads/master
Commit: 1f615a1b04813d2325868d4f6a32e8cd5b94b119
Parents: 7fb24d0
Author: rekathiru <rt...@gmail.com>
Authored: Tue Mar 4 09:58:58 2014 +0530
Committer: rekathiru <rt...@gmail.com>
Committed: Tue Mar 4 09:58:58 2014 +0530

----------------------------------------------------------------------
 .../rest/endpoint/services/ServiceUtils.java    | 26 +++++++++-----------
 1 file changed, 12 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/1f615a1b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
index f95d935..1d0dc36 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
@@ -367,6 +367,11 @@ public class ServiceUtils {
         if (autoscalerServiceClient != null) {
             try {
                 autoscalePolicies = autoscalerServiceClient.getAutoScalePolicies();
+                if(autoscalePolicies == null || autoscalePolicies.length == 0) {
+                    String errorMsg = "Cannot find any auto-scaling policy.";
+                    log.error(errorMsg);
+                    throw new RestAPIException(errorMsg);
+                }
 
             } catch (RemoteException e) {
                 String errorMsg = "Error while getting available autoscaling policies. Cause : " + e.getMessage();
@@ -374,13 +379,6 @@ public class ServiceUtils {
                 throw new RestAPIException(errorMsg, e);
             }
         }
-        
-        if(autoscalePolicies.length == 0) {
-        	String errorMsg = "Cannot find any auto-scaling policy.";
-            log.error(errorMsg);
-            throw new RestAPIException(errorMsg);
-        }
-
         return PojoConverter.populateAutoscalePojos(autoscalePolicies);
     }
 
@@ -417,7 +415,11 @@ public class ServiceUtils {
         if (autoscalerServiceClient != null) {
             try {
                 deploymentPolicies = autoscalerServiceClient.getDeploymentPolicies();
-
+                if(deploymentPolicies == null || deploymentPolicies.length == 0) {
+                    String errorMsg = "Cannot find any deployment policy.";
+                    log.error(errorMsg);
+                    throw new RestAPIException(errorMsg);
+                }
             } catch (RemoteException e) {
                 String errorMsg = "Error getting available deployment policies. Cause : " + e.getMessage();
                 log.error(errorMsg, e);
@@ -425,11 +427,7 @@ public class ServiceUtils {
             }
         }
         
-        if(deploymentPolicies.length == 0) {
-        	String errorMsg = "Cannot find any deployment policy.";
-            log.error(errorMsg);
-            throw new RestAPIException(errorMsg);
-        }
+
 
         return PojoConverter.populateDeploymentPolicyPojos(deploymentPolicies);
     }
@@ -535,7 +533,7 @@ public class ServiceUtils {
 			}
 		}
 		
-		if(lbCartridges.isEmpty()) {
+		if(lbCartridges == null || lbCartridges.isEmpty()) {
 			String msg = "Load balancer Cartridges are not available.";
 	        log.error(msg);
 	        throw new RestAPIException(msg) ;