Catch and log I/O exceptions thrown by #close() and #shutdown() methods

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@989328 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2010-08-25 19:57:51 +00:00
parent 29a4612386
commit 30eb471da7
1 changed files with 15 additions and 9 deletions

View File

@ -146,20 +146,26 @@ public class DefaultClientConnection extends SocketHttpClientConnection
*/ */
@Override @Override
public void shutdown() throws IOException { public void shutdown() throws IOException {
log.debug("Connection shut down");
shutdown = true; shutdown = true;
try {
super.shutdown(); super.shutdown();
Socket sock = this.socket; // copy volatile attribute log.debug("Connection shut down");
if (sock != null) Socket sock = this.socket; // copy volatile attribute
sock.close(); if (sock != null)
sock.close();
} catch (IOException ex) {
log.debug("I/O error shutting down connection", ex);
}
} }
@Override @Override
public void close() throws IOException { public void close() throws IOException {
log.debug("Connection closed"); try {
super.close(); super.close();
log.debug("Connection closed");
} catch (IOException ex) {
log.debug("I/O error closing connection", ex);
}
} }
@Override @Override