hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r818592 - in /httpcomponents/httpcore/branches/4.0.x: RELEASE_NOTES.txt httpcore/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java httpcore/src/main/java/org/apache/http/impl/SocketHttpServerConnection.java
Date Thu, 24 Sep 2009 19:06:36 GMT
Author: olegk
Date: Thu Sep 24 19:06:31 2009
New Revision: 818592

URL: http://svn.apache.org/viewvc?rev=818592&view=rev
Log:
HTTPCORE-207: SocketHttp*Connection classes can leak sockets if the connection is half-closed
Contributed by David Koski <david_koski at mac.com>

Modified:
    httpcomponents/httpcore/branches/4.0.x/RELEASE_NOTES.txt
    httpcomponents/httpcore/branches/4.0.x/httpcore/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java
    httpcomponents/httpcore/branches/4.0.x/httpcore/src/main/java/org/apache/http/impl/SocketHttpServerConnection.java

Modified: httpcomponents/httpcore/branches/4.0.x/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.0.x/RELEASE_NOTES.txt?rev=818592&r1=818591&r2=818592&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/4.0.x/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpcore/branches/4.0.x/RELEASE_NOTES.txt Thu Sep 24 19:06:31 2009
@@ -1,5 +1,8 @@
 Changes since 4.0.1
 
+* [HTTPCORE-207] SocketHttp*Connection classes can leak sockets if the connection is half-closed
+  Contributed by David Koski <david_koski at mac.com>
+
 * [HTTPCORE-201] OSGi Export-Package to specify release version
   Contributed by Oleg Kalnichevski <olegk at apache.org>
 

Modified: httpcomponents/httpcore/branches/4.0.x/httpcore/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.0.x/httpcore/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java?rev=818592&r1=818591&r2=818592&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/4.0.x/httpcore/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java
(original)
+++ httpcomponents/httpcore/branches/4.0.x/httpcore/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java
Thu Sep 24 19:06:31 2009
@@ -245,20 +245,24 @@
             return;
         }
         this.open = false;
-        doFlush();
+        Socket sock = this.socket;
         try {
+            doFlush();
             try {
-                this.socket.shutdownOutput();
-            } catch (IOException ignore) {
+                try {
+                    sock.shutdownOutput();
+                } catch (IOException ignore) {
+                }
+                try {
+                    sock.shutdownInput();
+                } catch (IOException ignore) {
+                }
+            } catch (UnsupportedOperationException ignore) {
+                // if one isn't supported, the other one isn't either
             }
-            try {
-                this.socket.shutdownInput();
-            } catch (IOException ignore) {
-            }
-        } catch (UnsupportedOperationException ignore) {
-            // if one isn't supported, the other one isn't either
+        } finally {
+            sock.close();
         }
-        this.socket.close();
     }
     
 }

Modified: httpcomponents/httpcore/branches/4.0.x/httpcore/src/main/java/org/apache/http/impl/SocketHttpServerConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.0.x/httpcore/src/main/java/org/apache/http/impl/SocketHttpServerConnection.java?rev=818592&r1=818591&r2=818592&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/4.0.x/httpcore/src/main/java/org/apache/http/impl/SocketHttpServerConnection.java
(original)
+++ httpcomponents/httpcore/branches/4.0.x/httpcore/src/main/java/org/apache/http/impl/SocketHttpServerConnection.java
Thu Sep 24 19:06:31 2009
@@ -262,20 +262,25 @@
             return;
         }
         this.open = false;
-        doFlush();
+        this.open = false;
+        Socket sock = this.socket;
         try {
+            doFlush();
             try {
-                this.socket.shutdownOutput();
-            } catch (IOException ignore) {
-            }
-            try {
-                this.socket.shutdownInput();
-            } catch (IOException ignore) {
+                try {
+                    sock.shutdownOutput();
+                } catch (IOException ignore) {
+                }
+                try {
+                    sock.shutdownInput();
+                } catch (IOException ignore) {
+                }
+            } catch (UnsupportedOperationException ignore) {
+                // if one isn't supported, the other one isn't either
             }
-        } catch (UnsupportedOperationException ignore) {
-            // if one isn't supported, the other one isn't either
+        } finally {
+            sock.close();
         }
-        this.socket.close();
     }
     
 }



Mime
View raw message