commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oglu...@apache.org
Subject svn commit: r514390 - in /jakarta/commons/proper/httpclient/trunk: ./ src/contrib/org/apache/commons/httpclient/contrib/ssl/ src/test/org/apache/commons/httpclient/ssl/
Date Sun, 04 Mar 2007 12:37:15 GMT
Author: oglueck
Date: Sun Mar  4 04:37:15 2007
New Revision: 514390

URL: http://svn.apache.org/viewvc?view=rev&rev=514390
Log:
Fixed resource leaks
PR: HTTPCLIENT-641
Contributed by Hanson Char
Reviewed by Ortwin Gl├╝ck

Modified:
    jakarta/commons/proper/httpclient/trunk/release_notes.txt
    jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/ssl/AuthSSLProtocolSocketFactory.java
    jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/ssl/SimpleSSLSocketFactory.java
    jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/ssl/SimpleSSLTestProtocolSocketFactory.java

Modified: jakarta/commons/proper/httpclient/trunk/release_notes.txt
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/release_notes.txt?view=diff&rev=514390&r1=514389&r2=514390
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/release_notes.txt (original)
+++ jakarta/commons/proper/httpclient/trunk/release_notes.txt Sun Mar  4 04:37:15 2007
@@ -1,4 +1,7 @@
 Changes since Release 3.1 Beta 1:
+* [HTTPCLIENT-641] - Resource Leakage when loading keystore in AuthSSLProtocolSocketFactory.
+           Contributed by Hanson Char
+
 * [HTTPCLIENT-634] - Default host config can override scheme of absolute URL.
            Contributed by John Kristian
 

Modified: jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/ssl/AuthSSLProtocolSocketFactory.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/ssl/AuthSSLProtocolSocketFactory.java?view=diff&rev=514390&r1=514389&r2=514390
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/ssl/AuthSSLProtocolSocketFactory.java
(original)
+++ jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/ssl/AuthSSLProtocolSocketFactory.java
Sun Mar  4 04:37:15 2007
@@ -31,6 +31,7 @@
 package org.apache.commons.httpclient.contrib.ssl;
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.Socket;
@@ -215,7 +216,13 @@
         }
         LOG.debug("Initializing key store");
         KeyStore keystore  = KeyStore.getInstance("jks");
-        keystore.load(url.openStream(), password != null ? password.toCharArray(): null);
+        InputStream is = null;
+        try {
+        	is = url.openStream(); 
+            keystore.load(is, password != null ? password.toCharArray(): null);
+        } finally {
+        	if (is != null) is.close();
+        }
         return keystore;
     }
     

Modified: jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/ssl/SimpleSSLSocketFactory.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/ssl/SimpleSSLSocketFactory.java?view=diff&rev=514390&r1=514389&r2=514390
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/ssl/SimpleSSLSocketFactory.java
(original)
+++ jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/ssl/SimpleSSLSocketFactory.java
Sun Mar  4 04:37:15 2007
@@ -31,6 +31,7 @@
 package org.apache.commons.httpclient.ssl;
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.ServerSocket;
 import java.net.URL;
 import java.security.KeyStore;
@@ -61,7 +62,13 @@
             ClassLoader cl = SimpleSocketFactory.class.getClassLoader();
             URL url = cl.getResource("org/apache/commons/httpclient/ssl/simpleserver.keystore");
             KeyStore keystore  = KeyStore.getInstance("jks");
-            keystore.load(url.openStream(), "nopassword".toCharArray());
+            InputStream is = null;
+            try {
+	            is = url.openStream();
+	            keystore.load(is, "nopassword".toCharArray());
+            } finally {
+            	if (is != null) is.close();
+            }
             KeyManagerFactory kmfactory = KeyManagerFactory.getInstance(
                     KeyManagerFactory.getDefaultAlgorithm());
             kmfactory.init(keystore, "nopassword".toCharArray());

Modified: jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/ssl/SimpleSSLTestProtocolSocketFactory.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/ssl/SimpleSSLTestProtocolSocketFactory.java?view=diff&rev=514390&r1=514389&r2=514390
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/ssl/SimpleSSLTestProtocolSocketFactory.java
(original)
+++ jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/ssl/SimpleSSLTestProtocolSocketFactory.java
Sun Mar  4 04:37:15 2007
@@ -31,6 +31,7 @@
 package org.apache.commons.httpclient.ssl;
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.InetAddress;
 import java.net.Socket;
 import java.net.URL;
@@ -60,7 +61,13 @@
             ClassLoader cl = SimpleSocketFactory.class.getClassLoader();
             URL url = cl.getResource("org/apache/commons/httpclient/ssl/simpleserver.keystore");
             KeyStore keystore  = KeyStore.getInstance("jks");
-            keystore.load(url.openStream(), "nopassword".toCharArray());
+            InputStream is = null;
+            try {
+            	is = url.openStream();
+            	keystore.load(is, "nopassword".toCharArray());
+            } finally {
+            	if (is != null) is.close();
+            }
             TrustManagerFactory tmfactory = TrustManagerFactory.getInstance(
                     TrustManagerFactory.getDefaultAlgorithm());
             tmfactory.init(keystore);



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message