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 b371356
Date Thu, 31 Jul 2014 15:51:18 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master 1cf1abcf4 -> b371356ab


Fixed coverity issues reported


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

Branch: refs/heads/master
Commit: b371356abc9fa74b3306fe2d6dd9f8b200233d67
Parents: 1cf1abc
Author: Santhosh Edukulla <santhosh.edukulla@gmail.com>
Authored: Thu Jul 31 18:31:16 2014 +0530
Committer: Santhosh Edukulla <santhosh.edukulla@gmail.com>
Committed: Thu Jul 31 21:19:57 2014 +0530

----------------------------------------------------------------------
 .../cloud/server/ConfigurationServerImpl.java   | 18 ++++----
 .../resource/NfsSecondaryStorageResource.java   | 43 +++++++++++---------
 2 files changed, 33 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b371356a/server/src/com/cloud/server/ConfigurationServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ConfigurationServerImpl.java b/server/src/com/cloud/server/ConfigurationServerImpl.java
index 60474c7..cb5956a 100755
--- a/server/src/com/cloud/server/ConfigurationServerImpl.java
+++ b/server/src/com/cloud/server/ConfigurationServerImpl.java
@@ -441,13 +441,15 @@ public class ConfigurationServerImpl extends ManagerBase implements
Configuratio
             if (propsFile == null) {
                 return null;
             } else {
-                final FileInputStream finputstream = new FileInputStream(propsFile);
                 final Properties props = new Properties();
-                props.load(finputstream);
-                finputstream.close();
+                try(final FileInputStream finputstream = new FileInputStream(propsFile);)
{
+                    props.load(finputstream);
+                }catch (IOException e) {
+                    s_logger.error("getEnvironmentProperty:Exception:" + e.getMessage());
+                }
                 return props.getProperty("mount.parent");
             }
-        } catch (IOException e) {
+        } catch (Exception e) {
             return null;
         }
     }
@@ -846,10 +848,10 @@ public class ConfigurationServerImpl extends ManagerBase implements
Configuratio
         }
 
         if (keyfile.exists()) {
-            try {
-                FileOutputStream kStream = new FileOutputStream(keyfile);
-                kStream.write(key.getBytes());
-                kStream.close();
+            try (FileOutputStream kStream = new FileOutputStream(keyfile);){
+                if (kStream != null) {
+                    kStream.write(key.getBytes());
+                }
             } catch (FileNotFoundException e) {
                 s_logger.warn("Failed to write  key to " + keyfile.getAbsolutePath());
                 throw new CloudRuntimeException("Failed to update keypairs on disk: cannot
find  key file " + keyPath);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b371356a/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
----------------------------------------------------------------------
diff --git a/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
b/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
index 0e625f3..7582b73 100755
--- a/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
+++ b/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
@@ -1361,28 +1361,31 @@ public class NfsSecondaryStorageResource extends ServerResourceBase
implements S
                     if (tmpFile == null) {
                         continue;
                     }
-                    FileReader fr = new FileReader(tmpFile);
-                    BufferedReader brf = new BufferedReader(fr);
-                    String line = null;
-                    String uniqName = null;
-                    Long size = null;
-                    String name = null;
-                    while ((line = brf.readLine()) != null) {
-                        if (line.startsWith("uniquename=")) {
-                            uniqName = line.split("=")[1];
-                        } else if (line.startsWith("size=")) {
-                            size = Long.parseLong(line.split("=")[1]);
-                        } else if (line.startsWith("filename=")) {
-                            name = line.split("=")[1];
+                    try (FileReader fr = new FileReader(tmpFile);
+                         BufferedReader brf = new BufferedReader(fr);) {
+                        String line = null;
+                        String uniqName = null;
+                        Long size = null;
+                        String name = null;
+                        while ((line = brf.readLine()) != null) {
+                            if (line.startsWith("uniquename=")) {
+                                uniqName = line.split("=")[1];
+                            } else if (line.startsWith("size=")) {
+                                size = Long.parseLong(line.split("=")[1]);
+                            } else if (line.startsWith("filename=")) {
+                                name = line.split("=")[1];
+                            }
                         }
+                        tempFile.delete();
+                        if (uniqName != null) {
+                            TemplateProp prop = new TemplateProp(uniqName, container + File.separator
+ name, size, size, true, false);
+                            tmpltInfos.put(uniqName, prop);
+                        }
+                    } catch (IOException ex)
+                    {
+                        s_logger.debug("swiftListTemplate:Exception:" + ex.getMessage());
+                        continue;
                     }
-                    brf.close();
-                    tempFile.delete();
-                    if (uniqName != null) {
-                        TemplateProp prop = new TemplateProp(uniqName, container + File.separator
+ name, size, size, true, false);
-                        tmpltInfos.put(uniqName, prop);
-                    }
-
                 } catch (IOException e) {
                     s_logger.debug("Failed to create templ file:" + e.toString());
                     continue;


Mime
View raw message