cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From santhosheduku...@apache.org
Subject git commit: updated refs/heads/master to cc725e5
Date Tue, 05 Aug 2014 09:29:47 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master 1bfb1f650 -> cc725e53e


Fixing Summary:Coverity findings for brocade-plugin


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

Branch: refs/heads/master
Commit: cc725e53e304781148a6bf077e05d844fe88207c
Parents: 1bfb1f6
Author: Ritu Sabharwal <rsabharw@brocade.com>
Authored: Tue Aug 5 14:59:15 2014 +0530
Committer: Santhosh Edukulla <santhosh.edukulla@gmail.com>
Committed: Tue Aug 5 14:59:15 2014 +0530

----------------------------------------------------------------------
 .../api/response/BrocadeVcsDeviceResponse.java  | 20 +++++++
 .../cloud/network/brocade/BrocadeVcsApi.java    | 56 ++++++++++++++------
 2 files changed, 61 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cc725e53/plugins/network-elements/brocade-vcs/src/com/cloud/api/response/BrocadeVcsDeviceResponse.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/src/com/cloud/api/response/BrocadeVcsDeviceResponse.java
b/plugins/network-elements/brocade-vcs/src/com/cloud/api/response/BrocadeVcsDeviceResponse.java
index 60edbcf..43b4e44 100644
--- a/plugins/network-elements/brocade-vcs/src/com/cloud/api/response/BrocadeVcsDeviceResponse.java
+++ b/plugins/network-elements/brocade-vcs/src/com/cloud/api/response/BrocadeVcsDeviceResponse.java
@@ -51,6 +51,26 @@ public class BrocadeVcsDeviceResponse extends BaseResponse {
     @Param(description = "the principal switch Ip address")
     private String hostName;
 
+    public String getId() {
+        return id;
+    }
+
+    public String getPhysicalNetworkId() {
+        return physicalNetworkId;
+    }
+
+    public String getProviderName() {
+        return providerName;
+    }
+
+    public String getDeviceName() {
+        return deviceName;
+    }
+
+    public String getHostName() {
+        return hostName;
+    }
+
     public void setId(String vcsDeviceId) {
         this.id = vcsDeviceId;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cc725e53/plugins/network-elements/brocade-vcs/src/com/cloud/network/brocade/BrocadeVcsApi.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/src/com/cloud/network/brocade/BrocadeVcsApi.java
b/plugins/network-elements/brocade-vcs/src/com/cloud/network/brocade/BrocadeVcsApi.java
index d5f06f8..dc111fd 100644
--- a/plugins/network-elements/brocade-vcs/src/com/cloud/network/brocade/BrocadeVcsApi.java
+++ b/plugins/network-elements/brocade-vcs/src/com/cloud/network/brocade/BrocadeVcsApi.java
@@ -334,7 +334,15 @@ public class BrocadeVcsApi {
         HttpResponse response = executeMethod(pm);
 
         if (response.getStatusLine().getStatusCode() != HttpStatus.SC_NO_CONTENT) {
-            String errorMessage = responseToErrorMessage(response);
+
+            String errorMessage;
+            try {
+                errorMessage = responseToErrorMessage(response);
+            } catch (IOException e) {
+                s_logger.error("Failed to update object : " + e.getMessage());
+                throw new BrocadeVcsApiException("Failed to update object : " + e.getMessage());
+            }
+
             pm.releaseConnection();
             s_logger.error("Failed to update object : " + errorMessage);
             throw new BrocadeVcsApiException("Failed to update object : " + errorMessage);
@@ -405,7 +413,15 @@ public class BrocadeVcsApi {
         HttpResponse response = executeMethod(pm);
 
         if (response.getStatusLine().getStatusCode() != HttpStatus.SC_CREATED) {
-            String errorMessage = responseToErrorMessage(response);
+
+            String errorMessage;
+            try {
+                errorMessage = responseToErrorMessage(response);
+            } catch (IOException e) {
+                s_logger.error("Failed to create object : " + e.getMessage());
+                throw new BrocadeVcsApiException("Failed to create object : " + e.getMessage());
+            }
+
             pm.releaseConnection();
             s_logger.error("Failed to create object : " + errorMessage);
             throw new BrocadeVcsApiException("Failed to create object : " + errorMessage);
@@ -421,7 +437,6 @@ public class BrocadeVcsApi {
             throw new BrocadeVcsApiException("Hostname/credentials are null or empty");
         }
 
-        BufferedReader br = null;
         String readLine = null;
         StringBuffer sb = null;
 
@@ -432,14 +447,21 @@ public class BrocadeVcsApi {
         HttpResponse response = executeMethod(pm);
 
         if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
-            String errorMessage = responseToErrorMessage(response);
+
+            String errorMessage;
+            try {
+                errorMessage = responseToErrorMessage(response);
+            } catch (IOException e) {
+                s_logger.error("Failed to retreive status : " + e.getMessage());
+                throw new BrocadeVcsApiException("Failed to retreive status : " + e.getMessage());
+            }
+
             pm.releaseConnection();
             s_logger.error("Failed to retreive status : " + errorMessage);
             throw new BrocadeVcsApiException("Failed to retreive status : " + errorMessage);
         }
 
-        try {
-            br = new BufferedReader(new InputStreamReader(response.getEntity().getContent(),
Charset.forName("UTF-8")));
+        try (BufferedReader br = new BufferedReader(new InputStreamReader(response.getEntity().getContent(),
Charset.forName("UTF-8")))) {
             sb = new StringBuffer();
 
             while (((readLine = br.readLine()) != null)) {
@@ -448,8 +470,8 @@ public class BrocadeVcsApi {
 
             }
         } catch (Exception e) {
-            s_logger.error("Failed to get object : " + e.getMessage());
-            throw new BrocadeVcsApiException("Failed to get object : " + e.getMessage());
+            s_logger.error("Failed to retreive status : " + e.getMessage());
+            throw new BrocadeVcsApiException("Failed to retreive status : " + e.getMessage());
         }
 
         pm.releaseConnection();
@@ -468,7 +490,15 @@ public class BrocadeVcsApi {
         HttpResponse response = executeMethod(dm);
 
         if (response.getStatusLine().getStatusCode() != HttpStatus.SC_NO_CONTENT) {
-            String errorMessage = responseToErrorMessage(response);
+
+            String errorMessage;
+            try {
+                errorMessage = responseToErrorMessage(response);
+            } catch (IOException e) {
+                s_logger.error("Failed to delete object : " + e.getMessage());
+                throw new BrocadeVcsApiException("Failed to delete object : " + e.getMessage());
+            }
+
             dm.releaseConnection();
             s_logger.error("Failed to delete object : " + errorMessage);
             throw new BrocadeVcsApiException("Failed to delete object : " + errorMessage);
@@ -497,22 +527,18 @@ public class BrocadeVcsApi {
         return response;
     }
 
-    private String responseToErrorMessage(HttpResponse response) {
+    private String responseToErrorMessage(HttpResponse response) throws IOException {
 
         if ("text/html".equals(response.getEntity().getContentType().getValue())) {
-            try {
 
-                BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent(),
Charset.forName("UTF-8")));
+            try (BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent(),
Charset.forName("UTF-8")))) {
 
                 StringBuffer result = new StringBuffer();
                 String line = "";
                 while ((line = rd.readLine()) != null) {
                     result.append(line);
                 }
-
                 return result.toString();
-            } catch (IOException e) {
-                s_logger.debug("Error while loading response body", e);
             }
         }
         return null;


Mime
View raw message