Skip to content

Commit b414b6d

Browse files
author
Stephane Landelle
committed
Minor clean up, port 1d965d7 to master
1 parent db8bf69 commit b414b6d

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

providers/netty/src/main/java/org/asynchttpclient/providers/netty/NettyAsyncHttpProvider.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,7 +1332,7 @@ public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws
13321332
p.onClose(ctx, e);
13331333

13341334
if (future != null && !future.isDone() && !future.isCancelled()) {
1335-
if (!remotelyClosed(ctx.getChannel(), future)) {
1335+
if (remotelyClosed(ctx.getChannel(), future)) {
13361336
abort(future, new IOException("Remotely Closed"));
13371337
}
13381338
} else {
@@ -1344,18 +1344,20 @@ public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws
13441344
protected boolean remotelyClosed(Channel channel, NettyResponseFuture<?> future) {
13451345

13461346
if (isClose.get()) {
1347-
return false;
1347+
return true;
13481348
}
13491349

13501350
connectionsPool.removeAll(channel);
13511351

1352-
if (future == null && channel.getPipeline().getContext(NettyAsyncHttpProvider.class).getAttachment() instanceof NettyResponseFuture) {
1353-
future = (NettyResponseFuture<?>) channel.getPipeline().getContext(NettyAsyncHttpProvider.class).getAttachment();
1352+
if (future == null) {
1353+
Object attachment = channel.getPipeline().getContext(NettyAsyncHttpProvider.class).getAttachment();
1354+
if (attachment instanceof NettyResponseFuture)
1355+
future = (NettyResponseFuture<?>) attachment;
13541356
}
13551357

13561358
if (future == null || future.cannotBeReplay()) {
13571359
log.debug("Unable to recover future {}\n", future);
1358-
return false;
1360+
return true;
13591361
}
13601362

13611363
future.setState(NettyResponseFuture.STATE.RECONNECTED);
@@ -1365,13 +1367,13 @@ protected boolean remotelyClosed(Channel channel, NettyResponseFuture<?> future)
13651367

13661368
try {
13671369
nextRequest(future.getRequest(), future);
1368-
return true;
1370+
return false;
13691371
} catch (IOException iox) {
13701372
future.setState(NettyResponseFuture.STATE.CLOSED);
13711373
future.abort(iox);
13721374
log.error("Remotely Closed, unable to recover", iox);
13731375
}
1374-
return false;
1376+
return true;
13751377
}
13761378

13771379
private void markAsDone(final NettyResponseFuture<?> future, final ChannelHandlerContext ctx) throws MalformedURLException {

0 commit comments

Comments
 (0)