logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1431914 - /logging/log4j/log4j2/trunk/log4j12-api/src/test/java/org/apache/log4j/util/SerializationTestHelper.java
Date Fri, 11 Jan 2013 07:03:26 GMT
Author: ggregory
Date: Fri Jan 11 07:03:26 2013
New Revision: 1431914

URL: http://svn.apache.org/viewvc?rev=1431914&view=rev
Log:
Resource leak: 'objIs' is never closed.

Modified:
    logging/log4j/log4j2/trunk/log4j12-api/src/test/java/org/apache/log4j/util/SerializationTestHelper.java

Modified: logging/log4j/log4j2/trunk/log4j12-api/src/test/java/org/apache/log4j/util/SerializationTestHelper.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j12-api/src/test/java/org/apache/log4j/util/SerializationTestHelper.java?rev=1431914&r1=1431913&r2=1431914&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j12-api/src/test/java/org/apache/log4j/util/SerializationTestHelper.java
(original)
+++ logging/log4j/log4j2/trunk/log4j12-api/src/test/java/org/apache/log4j/util/SerializationTestHelper.java
Fri Jan 11 07:03:26 2013
@@ -69,12 +69,14 @@ public class SerializationTestHelper {
      * @return deserialized object.
      * @throws Exception thrown on IO or deserialization exception.
      */
-    public static Object deserializeStream(final String witness)
-        throws Exception {
+    public static Object deserializeStream(final String witness) throws Exception {
         final FileInputStream fileIs = new FileInputStream(witness);
         final ObjectInputStream objIs = new ObjectInputStream(fileIs);
-
-        return objIs.readObject();
+        try {
+            return objIs.readObject();
+        } finally {
+            objIs.close();
+        }
     }
 
     /**



Mime
View raw message