Skip to content

Commit

Permalink
HTTPCORE-207: SocketHttp*Connection classes can leak sockets if the c…
Browse files Browse the repository at this point in the history
…onnection is half-closed

Contributed by David Koski <david_koski at mac.com>

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.0.x@818592 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
ok2c committed Sep 24, 2009
1 parent 0eb2f62 commit e9e665d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 20 deletions.
3 changes: 3 additions & 0 deletions RELEASE_NOTES.txt
@@ -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>

Expand Down
Expand Up @@ -245,20 +245,24 @@ public void close() throws IOException {
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();
}

}
Expand Up @@ -262,20 +262,25 @@ public void close() throws IOException {
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();
}

}

0 comments on commit e9e665d

Please sign in to comment.