Skip to content

Commit 6a2de0f

Browse files
committed
Clean up finishUpdate
Motivation: As ABORT now closes the channel and never tries to offer the channel to the pool, we no longer need an `expectOtherChunks` parameter. Modifications: * remove `expectOtherChunks` parameter * reverse keepAlive in to close Result: Removed dead path in code
1 parent 90124a5 commit 6a2de0f

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

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

+3-5
Original file line numberDiff line numberDiff line change
@@ -226,15 +226,13 @@ private boolean isHandledByReactiveStreams(ChannelHandlerContext ctx) {
226226
return Channels.getAttribute(ctx.channel()) instanceof StreamedResponsePublisher;
227227
}
228228

229-
protected void finishUpdate(NettyResponseFuture<?> future, Channel channel, boolean keepAlive, boolean expectOtherChunks) throws IOException {
229+
protected void finishUpdate(NettyResponseFuture<?> future, Channel channel, boolean close) throws IOException {
230230
future.cancelTimeouts();
231231

232-
if (!keepAlive) {
232+
if (close) {
233233
channelManager.closeChannel(channel);
234-
} else if (expectOtherChunks) {
235-
channelManager.drainChannelAndOffer(channel, future);
236234
} else {
237-
channelManager.tryToOfferChannelToPool(channel, future.getAsyncHandler(), keepAlive, future.getPartitionKey());
235+
channelManager.tryToOfferChannelToPool(channel, future.getAsyncHandler(), true, future.getPartitionKey());
238236
}
239237

240238
try {

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ private void handleHttpResponse(final HttpResponse response, final Channel chann
8787
abortAfterHandlingReactiveStreams(channel, future, handler);
8888

8989
if (abort) {
90-
finishUpdate(future, channel, false, true);
90+
finishUpdate(future, channel, true);
9191
}
9292
}
9393
}
@@ -116,8 +116,8 @@ private void handleChunk(HttpContent chunk,//
116116
}
117117

118118
if (abort || last) {
119-
boolean keepAlive = !abort && future.isKeepAlive();
120-
finishUpdate(future, channel, keepAlive, !last);
119+
boolean close = abort || !future.isKeepAlive();
120+
finishUpdate(future, channel, close);
121121
}
122122
}
123123

@@ -168,7 +168,7 @@ private void readFailed(Channel channel, NettyResponseFuture<?> future, Throwabl
168168
} catch (Exception abortException) {
169169
logger.debug("Abort failed", abortException);
170170
} finally {
171-
finishUpdate(future, channel, false, false);
171+
finishUpdate(future, channel, true);
172172
}
173173
}
174174

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ private void abort(Channel channel, NettyResponseFuture<?> future, WebSocketUpgr
8787
try {
8888
handler.onThrowable(new IOException("Invalid Status code=" + status.getStatusCode() + " text=" + status.getStatusText()));
8989
} finally {
90-
finishUpdate(future, channel, false, false);
90+
finishUpdate(future, channel, true);
9191
}
9292
}
9393

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

+1
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ public boolean applyIoExceptionFiltersAndReplayRequest(NettyResponseFuture<?> fu
527527
}
528528

529529
if (fc.replayRequest() && future.incrementRetryAndCheck() && future.isReplayPossible()) {
530+
future.setKeepAlive(false);
530531
replayRequest(future, fc, channel);
531532
replayed = true;
532533
}

0 commit comments

Comments
 (0)