logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
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 GMT
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"));
     }
 
 }



Mime
View raw message