Repository: stratos Updated Branches: refs/heads/container-autoscaling 9b6b3f831 -> df586b415
Fixing error handling in RestCommandLineService.executeList() Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/df586b41 Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/df586b41 Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/df586b41 Branch: refs/heads/container-autoscaling Commit: df586b4157d69f61f514f631cb2bbc0cdf0d1951 Parents: 9b6b3f8 Author: Imesh Gunaratne <[email protected]> Authored: Sat Oct 11 06:47:39 2014 +0530 Committer: Imesh Gunaratne <[email protected]> Committed: Sat Oct 11 06:47:39 2014 +0530 ---------------------------------------------------------------------- .../org/apache/stratos/cli/RestCommandLineService.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/df586b41/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java index 346c1af..02dd481 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java @@ -2116,14 +2116,17 @@ public class RestCommandLineService { try { response = restClient.doGet(httpClient, restClient.getBaseURL() + serviceEndpoint); int responseCode = response.getStatusLine().getStatusCode(); + String resultString = getHttpResponseString(response); - if (responseCode != 200) { - String resultString = getHttpResponseString(response); + GsonBuilder gsonBuilder = new GsonBuilder(); + Gson gson = gsonBuilder.create(); + + if (responseCode == 200) { + return gson.fromJson(resultString, _class); + } else { if(StringUtils.isBlank(resultString)) { return null; } else { - GsonBuilder gsonBuilder = new GsonBuilder(); - Gson gson = gsonBuilder.create(); ExceptionMapper exception = gson.fromJson(resultString, ExceptionMapper.class); if(exception != null) { System.out.println(exception); @@ -2131,7 +2134,6 @@ public class RestCommandLineService { return gson.fromJson(resultString, _class); } } - return null; } catch (Exception e) { handleException(String.format("Error in listing %s", entityName), e); return null;
