Return-Path: Delivered-To: apmail-hc-commits-archive@www.apache.org Received: (qmail 63215 invoked from network); 24 Sep 2009 19:08:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 24 Sep 2009 19:08:09 -0000 Received: (qmail 29155 invoked by uid 500); 24 Sep 2009 19:08:09 -0000 Delivered-To: apmail-hc-commits-archive@hc.apache.org Received: (qmail 29123 invoked by uid 500); 24 Sep 2009 19:08:09 -0000 Mailing-List: contact commits-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list commits@hc.apache.org Received: (qmail 29114 invoked by uid 99); 24 Sep 2009 19:08:09 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Sep 2009 19:08:09 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Sep 2009 19:08:07 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 316B623888FD; Thu, 24 Sep 2009 19:07:47 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@hc.apache.org From: olegk@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090924190747.316B623888FD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 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 + 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(); } }