Skip to content

Commit 16ba3c6

Browse files
ahus1vietj
authored andcommitted
Restore handling of headers after goaway received
This re-enables a graceful shutdown that was broken after ff78924 Closes #5693 (cherry picked from commit 9a399e2) # Conflicts: # src/main/java/io/vertx/core/http/impl/Http2ConnectionBase.java
1 parent f039681 commit 16ba3c6

File tree

2 files changed

+52
-10
lines changed

2 files changed

+52
-10
lines changed

src/main/java/io/vertx/core/http/impl/Http2ConnectionBase.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -202,20 +202,16 @@ public void onPriorityRead(ChannelHandlerContext ctx, int streamId, int streamDe
202202

203203
@Override
204204
public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int streamDependency, short weight, boolean exclusive, int padding, boolean endOfStream) throws Http2Exception {
205-
if (goAwayStatus == null) {
206-
StreamPriority streamPriority = new StreamPriority()
207-
.setDependency(streamDependency)
208-
.setWeight(weight)
209-
.setExclusive(exclusive);
210-
onHeadersRead(streamId, headers, streamPriority, endOfStream);
211-
}
205+
StreamPriority streamPriority = new StreamPriority()
206+
.setDependency(streamDependency)
207+
.setWeight(weight)
208+
.setExclusive(exclusive);
209+
onHeadersRead(streamId, headers, streamPriority, endOfStream);
212210
}
213211

214212
@Override
215213
public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int padding, boolean endOfStream) throws Http2Exception {
216-
if (goAwayStatus == null) {
217-
onHeadersRead(streamId, headers, null, endOfStream);
218-
}
214+
onHeadersRead(streamId, headers, null, endOfStream);
219215
}
220216

221217
protected abstract void onHeadersRead(int streamId, Http2Headers headers, StreamPriority streamPriority, boolean endOfStream);

src/test/java/io/vertx/core/http/Http2ClientTest.java

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,6 +1038,52 @@ public void testServerShutdownConnection() throws Exception {
10381038
await();
10391039
}
10401040

1041+
@Test
1042+
public void testServerGracefulShutdownBeforeHeaderSent() throws Exception {
1043+
server.requestHandler(req -> {
1044+
req.connection().shutdown();
1045+
req.response().end("OK");
1046+
});
1047+
startServer(testAddress);
1048+
1049+
client.request(requestOptions).compose(req -> req
1050+
.send()
1051+
.expecting(HttpResponseExpectation.SC_OK)
1052+
.compose(HttpClientResponse::end))
1053+
.andThen(resp -> {
1054+
if (resp.succeeded()) {
1055+
testComplete();
1056+
} else {
1057+
fail(resp.cause());
1058+
}
1059+
});
1060+
1061+
await();
1062+
}
1063+
1064+
@Test
1065+
public void testGoAwayErrorBeforeHeaderSent() throws Exception {
1066+
server.requestHandler(req -> {
1067+
req.connection().goAway(100);
1068+
req.response().end("OK");
1069+
});
1070+
startServer(testAddress);
1071+
1072+
client.request(requestOptions).compose(req -> req
1073+
.send()
1074+
.expecting(HttpResponseExpectation.SC_OK)
1075+
.compose(HttpClientResponse::end))
1076+
.andThen(resp -> {
1077+
if (resp.succeeded()) {
1078+
testComplete();
1079+
} else {
1080+
fail(resp.cause());
1081+
}
1082+
});
1083+
1084+
await();
1085+
}
1086+
10411087
@Test
10421088
public void testReceivingGoAwayDiscardsTheConnection() throws Exception {
10431089
AtomicInteger reqCount = new AtomicInteger();

0 commit comments

Comments
 (0)