NettyHttpClient: Replace ReadTimeoutException with our own exception. (#12635)

* NettyHttpClient: Replace ReadTimeoutException with our own exception.

* Replace exception with same type.

* Remove unused import.
This commit is contained in:
Gian Merlino 2022-06-14 13:34:46 -07:00 committed by GitHub
parent 6f7fa334fd
commit ceb4ace118
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -50,6 +50,7 @@ import org.jboss.netty.handler.codec.http.HttpMethod;
import org.jboss.netty.handler.codec.http.HttpRequest;
import org.jboss.netty.handler.codec.http.HttpResponse;
import org.jboss.netty.handler.codec.http.HttpVersion;
import org.jboss.netty.handler.timeout.ReadTimeoutException;
import org.jboss.netty.handler.timeout.ReadTimeoutHandler;
import org.jboss.netty.util.Timer;
import org.joda.time.Duration;
@ -316,7 +317,14 @@ public class NettyHttpClient extends AbstractHttpClient
}
}
retVal.setException(event.getCause());
if (event.getCause() instanceof ReadTimeoutException) {
// ReadTimeoutException thrown by ReadTimeoutHandler is a singleton with a misleading stack trace.
// No point including it: instead, we replace it with a fresh exception.
retVal.setException(new ReadTimeoutException(StringUtils.format("[%s] Read timed out", requestDesc)));
} else {
retVal.setException(event.getCause());
}
// response is non-null if we received initial chunk and then exception occurs
if (response != null) {
handler.exceptionCaught(response, event.getCause());