Return-Path: X-Original-To: apmail-tamaya-commits-archive@minotaur.apache.org Delivered-To: apmail-tamaya-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5064A17A43 for ; Tue, 10 Feb 2015 06:48:08 +0000 (UTC) Received: (qmail 9804 invoked by uid 500); 10 Feb 2015 06:48:08 -0000 Delivered-To: apmail-tamaya-commits-archive@tamaya.apache.org Received: (qmail 9780 invoked by uid 500); 10 Feb 2015 06:48:08 -0000 Mailing-List: contact commits-help@tamaya.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tamaya.incubator.apache.org Delivered-To: mailing list commits@tamaya.incubator.apache.org Received: (qmail 9771 invoked by uid 99); 10 Feb 2015 06:48:08 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Feb 2015 06:48:08 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 10 Feb 2015 06:47:46 +0000 Received: (qmail 6764 invoked by uid 99); 10 Feb 2015 06:47:43 -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; Tue, 10 Feb 2015 06:47:43 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id BFA01DFDDE; Tue, 10 Feb 2015 06:47:43 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: plexus@apache.org To: commits@tamaya.incubator.apache.org Message-Id: <0733c78a0c794725ad2a213446589684@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: incubator-tamaya git commit: TAMAYA-57 PropertiesFileLoader uses now try-with-resources to read a resource. Date: Tue, 10 Feb 2015 06:47:43 +0000 (UTC) X-Virus-Checked: Checked by ClamAV on apache.org Repository: incubator-tamaya Updated Branches: refs/heads/master ab4835d31 -> a832de494 TAMAYA-57 PropertiesFileLoader uses now try-with-resources to read a resource. Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/a832de49 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/a832de49 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/a832de49 Branch: refs/heads/master Commit: a832de49445289f60e5dcaefe9d406fb2a39c61c Parents: ab4835d Author: Oliver B. Fischer Authored: Tue Feb 10 07:47:09 2015 +0100 Committer: Oliver B. Fischer Committed: Tue Feb 10 07:47:09 2015 +0100 ---------------------------------------------------------------------- .../tamaya/core/internal/PropertiesFileLoader.java | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a832de49/java8/core/src/main/java/org/apache/tamaya/core/internal/PropertiesFileLoader.java ---------------------------------------------------------------------- diff --git a/java8/core/src/main/java/org/apache/tamaya/core/internal/PropertiesFileLoader.java b/java8/core/src/main/java/org/apache/tamaya/core/internal/PropertiesFileLoader.java index becb4bb..3e2f550 100644 --- a/java8/core/src/main/java/org/apache/tamaya/core/internal/PropertiesFileLoader.java +++ b/java8/core/src/main/java/org/apache/tamaya/core/internal/PropertiesFileLoader.java @@ -18,6 +18,8 @@ */ package org.apache.tamaya.core.internal; +import org.apache.tamaya.ConfigException; + import java.io.IOException; import java.io.InputStream; import java.net.URL; @@ -70,23 +72,13 @@ public final class PropertiesFileLoader { Properties properties = new Properties(); - InputStream stream = null; - try { - stream = propertiesFile.openStream(); + try (InputStream stream = propertiesFile.openStream()) { if (stream != null) { properties.load(stream); } } catch (IOException e) { - throw new IllegalStateException("Error loading Properties " + propertiesFile, e); - } finally { - if (stream != null) { - try { - stream.close(); - } catch (IOException e) { - // bad luck -> stream is already closed - } - } + throw new ConfigException("Error loading properties " + propertiesFile, e); } return properties;