Skip to content

Commit b8a4171

Browse files
committed
Reuse HTTP/2 connections that receive a 5xx error
1 parent c128d71 commit b8a4171

File tree

4 files changed

+2
-21
lines changed

4 files changed

+2
-21
lines changed

http-clients/aws-crt-client/src/main/java/software/amazon/awssdk/http/crt/internal/response/ResponseHandlerHelper.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import software.amazon.awssdk.crt.http.HttpHeader;
2121
import software.amazon.awssdk.crt.http.HttpHeaderBlock;
2222
import software.amazon.awssdk.crt.http.HttpStream;
23-
import software.amazon.awssdk.http.HttpStatusFamily;
2423
import software.amazon.awssdk.http.SdkHttpResponse;
2524

2625
/**

http-clients/aws-crt-client/src/test/java/software/amazon/awssdk/http/crt/internal/BaseHttpStreamResponseHandlerTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ void serverError_shouldShutdownConnection() {
7777
responseHandler.onResponseHeadersDone(httpStream, 0);
7878
responseHandler.onResponseComplete(httpStream, 0);
7979
requestFuture.join();
80-
verify(crtConn).shutdown();
8180
verify(crtConn).close();
8281
verify(httpStream).close();
8382
}
@@ -121,7 +120,6 @@ void streamClosed_shouldNotIncreaseStreamWindow() throws InterruptedException {
121120

122121
responseHandler.onResponseComplete(httpStream, 0);
123122
requestFuture.join();
124-
verify(crtConn).shutdown();
125123
verify(crtConn).close();
126124
verify(httpStream).close();
127125
verify(httpStream, never()).incrementWindow(anyInt());

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package software.amazon.awssdk.http.nio.netty.internal.http2;
1717

1818
import io.netty.buffer.ByteBuf;
19-
import io.netty.channel.Channel;
2019
import io.netty.channel.ChannelHandlerContext;
2120
import io.netty.channel.SimpleChannelInboundHandler;
2221
import io.netty.handler.codec.http.DefaultHttpContent;
@@ -32,7 +31,6 @@
3231
import io.netty.handler.codec.http2.HttpConversionUtil;
3332
import java.io.IOException;
3433
import software.amazon.awssdk.annotations.SdkInternalApi;
35-
import software.amazon.awssdk.http.HttpStatusFamily;
3634
import software.amazon.awssdk.http.nio.netty.internal.utils.NettyClientLogger;
3735

3836
/**
@@ -62,20 +60,6 @@ private void onHeadersRead(Http2HeadersFrame headersFrame, ChannelHandlerContext
6260

6361
HttpResponse httpResponse = HttpConversionUtil.toHttpResponse(headersFrame.stream().id(), headersFrame.headers(), true);
6462
ctx.fireChannelRead(httpResponse);
65-
66-
if (HttpStatusFamily.of(httpResponse.status().code()) == HttpStatusFamily.SERVER_ERROR) {
67-
fireConnectionExceptionForServerError(ctx);
68-
}
69-
}
70-
71-
private void fireConnectionExceptionForServerError(ChannelHandlerContext ctx) {
72-
if (ctx.channel().parent() != null) {
73-
Channel parent = ctx.channel().parent();
74-
log.debug(ctx.channel(),
75-
() -> "A 5xx server error occurred on an Http2 stream, notifying the connection channel " + ctx.channel());
76-
parent.pipeline().fireExceptionCaught(new Http2ConnectionTerminatingException("A 5xx server error occurred on an "
77-
+ "Http2 stream " + ctx.channel()));
78-
}
7963
}
8064

8165
private void onDataRead(Http2DataFrame dataFrame, ChannelHandlerContext ctx) throws Http2Exception {

http-clients/netty-nio-client/src/test/java/software/amazon/awssdk/http/nio/netty/fault/H2ServerErrorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@ public void teardown() throws InterruptedException {
8888
}
8989

9090
@Test
91-
public void serviceReturn500_newRequestShouldUseNewConnection() {
91+
public void serviceReturn500_newRequestShouldReuseConnection() {
9292
server.return500OnFirstRequest = true;
9393
CompletableFuture<?> firstRequest = sendGetRequest(server.port(), netty);
9494
firstRequest.join();
9595

9696
sendGetRequest(server.port(), netty).join();
97-
assertThat(server.h2ConnectionCount.get()).isEqualTo(2);
97+
assertThat(server.h2ConnectionCount.get()).isEqualTo(1);
9898
}
9999

100100
@Test

0 commit comments

Comments
 (0)