hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r818593 - in /httpcomponents/httpcore/trunk: 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:07:39 GMT
Author: olegk
Date: Thu Sep 24 19:07:33 2009
New Revision: 818593

URL: http://svn.apache.org/viewvc?rev=818593&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/trunk/RELEASE_NOTES.txt
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/SocketHttpServerConnection.java

Modified: httpcomponents/httpcore/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt?rev=818593&r1=818592&r2=818593&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpcore/trunk/RELEASE_NOTES.txt Thu Sep 24 19:07:33 2009
@@ -1,3 +1,8 @@
+Changes since 4.1-ALPHA1
+
+* [HTTPCORE-207] SocketHttp*Connection classes can leak sockets if the connection is half-closed
+  Contributed by David Koski <david_koski at mac.com>
+
 Release 4.1-ALPHA1
 -------------------
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java?rev=818593&r1=818592&r2=818593&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java
Thu Sep 24 19:07:33 2009
@@ -240,20 +240,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/trunk/httpcore/src/main/java/org/apache/http/impl/SocketHttpServerConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/SocketHttpServerConnection.java?rev=818593&r1=818592&r2=818593&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/SocketHttpServerConnection.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/SocketHttpServerConnection.java
Thu Sep 24 19:07:33 2009
@@ -257,20 +257,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