Skip to content

Commit 188dc72

Browse files
committed
Not throwing FutureCancelledException if it doesn't have executionId.
1 parent 0ca6b28 commit 188dc72

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

http-clients/netty-nio-client/src/main/java/software/amazon/awssdk/http/nio/netty/internal/FutureCancelHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable e) {
5151

5252
if (channelExecutionId == null) {
5353
RequestContext requestContext = ctx.channel().attr(REQUEST_CONTEXT_KEY).get();
54-
LOG.debug(ctx.channel(), () -> String.format("Received a cancellation exception on a channel that doesn't have an "
55-
+ "execution Id attached yet. Exception's execution ID is %d. "
54+
LOG.warn(ctx.channel(), () -> String.format("Received a cancellation exception on a channel that doesn't have an "
55+
+ "execution Id attached. Exception's execution ID is %d. "
5656
+ "Exception is being ignored. Closing the channel",
5757
executionId(ctx)));
5858
ctx.close();

http-clients/netty-nio-client/src/main/java/software/amazon/awssdk/http/nio/netty/internal/NettyRequestExecutor.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import io.netty.handler.codec.http.HttpVersion;
4343
import io.netty.handler.timeout.ReadTimeoutHandler;
4444
import io.netty.handler.timeout.WriteTimeoutHandler;
45+
import io.netty.util.Attribute;
4546
import io.netty.util.concurrent.Future;
4647
import io.netty.util.concurrent.GenericFutureListener;
4748
import io.netty.util.concurrent.Promise;
@@ -130,8 +131,9 @@ private CompletableFuture<Void> createExecutionFuture(Promise<Channel> channelPr
130131
Channel ch = channelPromise.getNow();
131132
try {
132133
ch.eventLoop().submit(() -> {
133-
if (ch.attr(IN_USE).get()) {
134-
ch.pipeline().fireExceptionCaught(new FutureCancelledException(executionId, t));
134+
Attribute<Long> executionIdKey = ch.attr(EXECUTION_ID_KEY);
135+
if (ch.attr(IN_USE) != null && ch.attr(IN_USE).get() && executionIdKey != null) {
136+
ch.pipeline().fireExceptionCaught(new FutureCancelledException(this.executionId, t));
135137
} else {
136138
ch.close().addListener(closeFuture -> context.channelPool().release(ch));
137139
}

http-clients/netty-nio-client/src/test/java/software/amazon/awssdk/http/nio/netty/internal/FutureCancelHandlerTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
import io.netty.channel.Channel;
2727
import io.netty.channel.ChannelHandlerContext;
28+
import io.netty.channel.DefaultChannelId;
2829
import io.netty.channel.EventLoopGroup;
2930
import io.netty.util.DefaultAttributeMap;
3031
import java.io.IOException;
@@ -77,6 +78,7 @@ public void methodSetup() {
7778
when(ctx.channel()).thenReturn(channel);
7879
when(channel.attr(EXECUTION_ID_KEY)).thenReturn(attrMap.attr(EXECUTION_ID_KEY));
7980
when(channel.attr(REQUEST_CONTEXT_KEY)).thenReturn(attrMap.attr(REQUEST_CONTEXT_KEY));
81+
when(channel.id()).thenReturn(DefaultChannelId.newInstance());
8082
}
8183

8284
@Test

0 commit comments

Comments
 (0)