You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ek...@apache.org on 2015/06/08 11:45:47 UTC
[26/50] [abbrv] git commit: updated refs/heads/feature/vpc-ipv6 to
6140db5
CID 1302974: Scanner in try-with-resource
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
This closes #353
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/109b6e94
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/109b6e94
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/109b6e94
Branch: refs/heads/feature/vpc-ipv6
Commit: 109b6e94d39d7c6db4ff721c4699e42abe47ec5e
Parents: 9c2a1ea
Author: Daan Hoogland <da...@gmail.com>
Authored: Wed Jun 3 17:37:13 2015 +0200
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Thu Jun 4 00:09:16 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/109b6e94/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());
}