cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [1/2] git commit: updated refs/heads/4.5 to 5fb86ae
Date Wed, 03 Jun 2015 22:10:29 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/4.5 d55d45348 -> 5fb86ae31


CID 1302974: Scanner in try-with-resource

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

This closes #353

(cherry picked from commit 109b6e94d39d7c6db4ff721c4699e42abe47ec5e)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>


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

Branch: refs/heads/4.5
Commit: fb50283fbe7875ce64992e268fb9ad5792e75962
Parents: d55d453
Author: Daan Hoogland <daan.hoogland@gmail.com>
Authored: Wed Jun 3 17:37:13 2015 +0200
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Thu Jun 4 00:10:05 2015 +0200

----------------------------------------------------------------------
 .../src/org/apache/cloudstack/utils/linux/MemStat.java | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fb50283f/plugins/hypervisors/kvm/src/org/apache/cloudstack/utils/linux/MemStat.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/org/apache/cloudstack/utils/linux/MemStat.java b/plugins/hypervisors/kvm/src/org/apache/cloudstack/utils/linux/MemStat.java
index 1e3c872..1d6a4fc 100644
--- a/plugins/hypervisors/kvm/src/org/apache/cloudstack/utils/linux/MemStat.java
+++ b/plugins/hypervisors/kvm/src/org/apache/cloudstack/utils/linux/MemStat.java
@@ -16,11 +16,10 @@
 // under the License.
 package org.apache.cloudstack.utils.linux;
 
-import java.util.HashMap;
-import java.util.Map;
-
 import java.io.File;
 import java.io.FileNotFoundException;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Scanner;
 
 public class MemStat {
@@ -29,7 +28,7 @@ public class MemStat {
     protected final static String CACHE_KEY = "Cached";
     protected final static String TOTAL_KEY = "MemTotal";
 
-    private Map<String, Double> _memStats = new HashMap<String, Double>();
+    private final Map<String, Double> _memStats = new HashMap<String, Double>();
 
     public MemStat() {
     }
@@ -51,9 +50,9 @@ public class MemStat {
     }
 
     public void refresh() {
-        try {
-            Scanner fileScanner = new Scanner(new File(MEMINFO_FILE));
-            parseFromScanner(fileScanner);
+        File f = new File(MEMINFO_FILE);
+        try (Scanner scanner = new Scanner(f)) {
+            parseFromScanner(scanner);
         } catch (FileNotFoundException ex) {
             throw new RuntimeException("File " + MEMINFO_FILE + " not found:" + ex.toString());
         }


Mime
View raw message