Return-Path: X-Original-To: apmail-logging-commits-archive@minotaur.apache.org Delivered-To: apmail-logging-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 4B7F8E58D for ; Fri, 11 Jan 2013 07:39:18 +0000 (UTC) Received: (qmail 52983 invoked by uid 500); 11 Jan 2013 07:39:18 -0000 Delivered-To: apmail-logging-commits-archive@logging.apache.org Received: (qmail 52523 invoked by uid 500); 11 Jan 2013 07:39:17 -0000 Mailing-List: contact commits-help@logging.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@logging.apache.org Delivered-To: mailing list commits@logging.apache.org Received: (qmail 52492 invoked by uid 99); 11 Jan 2013 07:39:17 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Jan 2013 07:39:17 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Jan 2013 07:39:02 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 4F6ED23889DA; Fri, 11 Jan 2013 07:38:43 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1431926 - /logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/config/XMLConfigurationTest.java Date: Fri, 11 Jan 2013 07:38:43 -0000 To: commits@logging.apache.org From: ggregory@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130111073843.4F6ED23889DA@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ggregory Date: Fri Jan 11 07:38:42 2013 New Revision: 1431926 URL: http://svn.apache.org/viewvc?rev=1431926&view=rev Log: Fix stream resource leak. Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/config/XMLConfigurationTest.java Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/config/XMLConfigurationTest.java URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/config/XMLConfigurationTest.java?rev=1431926&r1=1431925&r2=1431926&view=diff ============================================================================== --- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/config/XMLConfigurationTest.java (original) +++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/config/XMLConfigurationTest.java Fri Jan 11 07:38:42 2013 @@ -105,14 +105,18 @@ public class XMLConfigurationTest { final Logger logger = LogManager.getLogger("org.apache.logging.log4j.test2.Test"); logger.debug("This is a test"); final DataInputStream is = new DataInputStream(new BufferedInputStream(new FileInputStream(LOGFILE))); - int count = 0; - String str = ""; - while (is.available() != 0) { - str = is.readLine(); - ++count; + try { + int count = 0; + String str = ""; + while (is.available() != 0) { + str = is.readLine(); + ++count; + } + assertTrue("Incorrect count " + count, count == 1); + assertTrue("Bad data", str.endsWith("This is a test")); + } finally { + is.close(); } - assertTrue("Incorrect count " + count, count == 1); - assertTrue("Bad data", str.endsWith("This is a test")); } }