logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1516679 - /logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/jmx/LoggerContextAdmin.java
Date Fri, 23 Aug 2013 02:13:01 GMT
Author: ggregory
Date: Fri Aug 23 02:13:00 2013
New Revision: 1516679

URL: http://svn.apache.org/r1516679
Log:
Clean up resource management after discussion with Remko on the ML.

Modified:
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/jmx/LoggerContextAdmin.java

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/jmx/LoggerContextAdmin.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/jmx/LoggerContextAdmin.java?rev=1516679&r1=1516678&r2=1516679&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/jmx/LoggerContextAdmin.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/jmx/LoggerContextAdmin.java
Fri Aug 23 02:13:00 2013
@@ -195,13 +195,10 @@ public class LoggerContextAdmin extends 
      * @throws IOException
      */
     private String readContents(final URI uri, final Charset charset) throws IOException
{
-        if (charset == null) {
-            throw new IllegalArgumentException("charset must not be null");
-        }
+        InputStream in = null;
         Reader reader = null;
         try {
-            InputStream in = uri.toURL().openStream();
-            // The stream is open and charset is not null, we can create the reader safely
without a possible NPE.
+            in = uri.toURL().openStream();
             reader = new InputStreamReader(in, charset);
             final StringBuilder result = new StringBuilder(TEXT_BUFFER);
             final char[] buff = new char[PAGE];
@@ -212,6 +209,13 @@ public class LoggerContextAdmin extends 
             return result.toString();
         } finally {
             try {
+                if (in != null) {
+                    in.close();
+                }
+            } catch (final Exception ignored) {
+                // ignored
+            }
+            try {
                 if (reader != null) {
                     reader.close();
                 }



Mime
View raw message