Skip to content

Commit 9a399e2

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
1 parent 7ee44a0 commit 9a399e2

File tree

2 files changed

+52
-10
lines changed

2 files changed

+52
-10
lines changed

vertx-core/src/main/java/io/vertx/core/http/impl/http2/codec/Http2ConnectionImpl.java

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

195195
@Override
196196
public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int streamDependency, short weight, boolean exclusive, int padding, boolean endOfStream) throws Http2Exception {
197-
if (goAwayStatus == null || endOfStream) {
198-
StreamPriority streamPriority = new StreamPriority()
199-
.setDependency(streamDependency)
200-
.setWeight(weight)
201-
.setExclusive(exclusive);
202-
onHeadersRead(streamId, headers, streamPriority, endOfStream);
203-
}
197+
StreamPriority streamPriority = new StreamPriority()
198+
.setDependency(streamDependency)
199+
.setWeight(weight)
200+
.setExclusive(exclusive);
201+
onHeadersRead(streamId, headers, streamPriority, endOfStream);
204202
}
205203

206204
@Override
207205
public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int padding, boolean endOfStream) throws Http2Exception {
208-
if (goAwayStatus == null || endOfStream) {
209-
onHeadersRead(streamId, headers, null, endOfStream);
210-
}
206+
onHeadersRead(streamId, headers, null, endOfStream);
211207
}
212208

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

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

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,6 +1069,52 @@ public void testServerShutdownConnection() throws Exception {
10691069
await();
10701070
}
10711071

1072+
@Test
1073+
public void testServerGracefulShutdownBeforeHeaderSent() throws Exception {
1074+
server.requestHandler(req -> {
1075+
req.connection().shutdown();
1076+
req.response().end("OK");
1077+
});
1078+
startServer(testAddress);
1079+
1080+
client.request(requestOptions).compose(req -> req
1081+
.send()
1082+
.expecting(HttpResponseExpectation.SC_OK)
1083+
.compose(HttpClientResponse::end))
1084+
.andThen(resp -> {
1085+
if (resp.succeeded()) {
1086+
testComplete();
1087+
} else {
1088+
fail(resp.cause());
1089+
}
1090+
});
1091+
1092+
await();
1093+
}
1094+
1095+
@Test
1096+
public void testGoAwayErrorBeforeHeaderSent() throws Exception {
1097+
server.requestHandler(req -> {
1098+
req.connection().goAway(100);
1099+
req.response().end("OK");
1100+
});
1101+
startServer(testAddress);
1102+
1103+
client.request(requestOptions).compose(req -> req
1104+
.send()
1105+
.expecting(HttpResponseExpectation.SC_OK)
1106+
.compose(HttpClientResponse::end))
1107+
.andThen(resp -> {
1108+
if (resp.succeeded()) {
1109+
testComplete();
1110+
} else {
1111+
fail(resp.cause());
1112+
}
1113+
});
1114+
1115+
await();
1116+
}
1117+
10721118
@Test
10731119
public void testReceivingGoAwayDiscardsTheConnection() throws Exception {
10741120
AtomicInteger connCount = new AtomicInteger();

0 commit comments

Comments
 (0)