BasicManagedEntity#streamClosed no longer propagates SocketException if the underlying connection has been shut down

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1307766 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2012-03-31 11:16:45 +00:00
parent 218edab9fd
commit d544026bee
1 changed files with 10 additions and 2 deletions

View File

@ -30,6 +30,7 @@ package org.apache.http.conn;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.SocketException;
import org.apache.http.annotation.NotThreadSafe;
@ -147,10 +148,17 @@ public class BasicManagedEntity extends HttpEntityWrapper
public boolean streamClosed(InputStream wrapped) throws IOException {
try {
if (attemptReuse && (managedConn != null)) {
boolean valid = managedConn.isOpen();
// this assumes that closing the stream will
// consume the remainder of the response body:
wrapped.close();
managedConn.markReusable();
try {
wrapped.close();
managedConn.markReusable();
} catch (SocketException ex) {
if (valid) {
throw ex;
}
}
}
} finally {
releaseManagedConnection();