Skip to content

Commit 01c0a98

Browse files
committed
Notify with original exception
1 parent e7798c8 commit 01c0a98

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

client/src/main/java/org/asynchttpclient/netty/NettyResponseFuture.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public final class NettyResponseFuture<V> extends AbstractListenableFuture<V> {
9090
private boolean allowConnect;
9191
private Realm realm;
9292
private Realm proxyRealm;
93+
public Throwable pendingException;
9394

9495
public NettyResponseFuture(Request originalRequest,//
9596
AsyncHandler<V> asyncHandler,//
@@ -325,7 +326,7 @@ public int incrementAndGetCurrentRedirectCount() {
325326
public void setTimeoutsHolder(TimeoutsHolder timeoutsHolder) {
326327
this.timeoutsHolder = timeoutsHolder;
327328
}
328-
329+
329330
public TimeoutsHolder getTimeoutsHolder() {
330331
return timeoutsHolder;
331332
}

client/src/main/java/org/asynchttpclient/netty/handler/AsyncHttpClientHandler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable e) throws Excep
195195

196196
if (StackTraceInspector.recoverOnReadOrWriteException(cause)) {
197197
logger.debug("Trying to recover from dead Channel: {}", channel);
198+
future.pendingException = cause;
198199
return;
199200
}
200201
} else if (attribute instanceof Callback) {

client/src/main/java/org/asynchttpclient/netty/request/NettyRequestSender.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,10 +383,13 @@ public void abort(Channel channel, NettyResponseFuture<?> future, Throwable t) {
383383
}
384384

385385
public void handleUnexpectedClosedChannel(Channel channel, NettyResponseFuture<?> future) {
386-
if (future.isDone())
386+
if (future.isDone()) {
387387
channelManager.closeChannel(channel);
388-
else if (!retry(future))
389-
abort(channel, future, RemotelyClosedException.INSTANCE);
388+
} else if (retry(future)) {
389+
future.pendingException = null;
390+
} else {
391+
abort(channel, future, future.pendingException != null? future.pendingException : RemotelyClosedException.INSTANCE);
392+
}
390393
}
391394

392395
public boolean retry(NettyResponseFuture<?> future) {

0 commit comments

Comments
 (0)