Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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() {
}
Expand All @@ -51,9 +50,9 @@ public Double getCache() {
}

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());
}
Expand Down