Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CCA2417683 for ; Wed, 3 Jun 2015 22:10:30 +0000 (UTC) Received: (qmail 29714 invoked by uid 500); 3 Jun 2015 22:10:29 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 29676 invoked by uid 500); 3 Jun 2015 22:10:29 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 29666 invoked by uid 99); 3 Jun 2015 22:10:29 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Jun 2015 22:10:29 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 47724E2F9B; Wed, 3 Jun 2015 22:10:29 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: bhaisaab@apache.org To: commits@cloudstack.apache.org Date: Wed, 03 Jun 2015 22:10:29 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/2] git commit: updated refs/heads/4.5 to 5fb86ae Repository: cloudstack Updated Branches: refs/heads/4.5 d55d45348 -> 5fb86ae31 CID 1302974: Scanner in try-with-resource Signed-off-by: Rohit Yadav This closes #353 (cherry picked from commit 109b6e94d39d7c6db4ff721c4699e42abe47ec5e) Signed-off-by: Rohit Yadav 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 Authored: Wed Jun 3 17:37:13 2015 +0200 Committer: Rohit Yadav 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 _memStats = new HashMap(); + private final Map _memStats = new HashMap(); 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()); }