Skip to content

Commit f961f29

Browse files
committed
Add fixes and tests for GOAWAY
- Ensure that the GOAWAY exception is fired within each child channel's event loop to ensure correct ordering - Fix off-by-one error in MultiplexedChannelRecord - Add tests using a minimal H2 endpoint implementation - Remove test-server module since it's no longer needed
1 parent 5f781f1 commit f961f29

File tree

16 files changed

+349
-637
lines changed

16 files changed

+349
-637
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"type": "bugfix",
3+
"category": "Netty NIO HTTP Client",
4+
"description": "Better handle `GOAWAY` messages from the remote endpoint."
5+
}

http-clients/netty-nio-client/pom.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,6 @@
9797
</dependency>
9898

9999
<!--Test Dependencies-->
100-
<dependency>
101-
<groupId>software.amazon.awssdk</groupId>
102-
<artifactId>test-server</artifactId>
103-
<version>${awsjavasdk.version}</version>
104-
<scope>test</scope>
105-
</dependency>
106100
<dependency>
107101
<groupId>com.github.tomakehurst</groupId>
108102
<artifactId>wiremock</artifactId>

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,12 @@ MultiplexedChannelRecord acquire(Promise<Channel> channelPromise) {
103103
* streams newer than the last-stream-id on the go-away frame.
104104
*/
105105
public void goAway(Http2GoAwayFrame frame) {
106-
System.out.println("Got GOAWAY: " + frame);
107106
this.goAway = true;
108-
doInEventLoop(connection.eventLoop(), () -> {
109-
GoAwayException exception = new GoAwayException(frame.errorCode(), frame.content());
110-
childChannels.entrySet().stream()
111-
.filter(c -> c.getValue().stream().id() > frame.lastStreamId())
112-
.forEach(c -> shutdownChildChannel(c.getValue(), exception));
113-
});
107+
GoAwayException exception = new GoAwayException(frame.errorCode(), frame.content());
108+
childChannels.entrySet().stream()
109+
.map(Map.Entry::getValue)
110+
.filter(cc -> cc.stream().id() > frame.lastStreamId())
111+
.forEach(cc -> cc.eventLoop().execute(() -> shutdownChildChannel(cc, exception)));
114112
}
115113

116114
/**
@@ -141,7 +139,7 @@ private void createChildChannel(Promise<Channel> channelPromise) {
141139
}
142140

143141
private void createChildChannel0(Promise<Channel> channelPromise) {
144-
if (availableStreams() <= 0) {
142+
if (goAway) {
145143
channelPromise.tryFailure(new IOException("No streams are available on this connection."));
146144
} else {
147145
// Once protocol future is notified then parent pipeline is configured and ready to go

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

Lines changed: 0 additions & 121 deletions
This file was deleted.

0 commit comments

Comments
 (0)