Skip to content

Commit

Permalink
frame and multiplex coded set gracefulclose timer to 0 for backwards …
Browse files Browse the repository at this point in the history
…compatbiilty
  • Loading branch information
Scottmitch committed Apr 27, 2019
1 parent 01281c6 commit 2ffd428
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public class Http2FrameCodecBuilder extends

Http2FrameCodecBuilder(boolean server) {
server(server);
// For backwards compatibility we should disable to timeout by default at this layer.
gracefulShutdownTimeoutMillis(0);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public class Http2MultiplexCodecBuilder
Http2MultiplexCodecBuilder(boolean server, ChannelHandler childHandler) {
server(server);
this.childHandler = checkSharable(checkNotNull(childHandler, "childHandler"));
// For backwards compatibility we should disable to timeout by default at this layer.
gracefulShutdownTimeoutMillis(0);
}

private static ChannelHandler checkSharable(ChannelHandler handler) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private void setUp(Http2FrameCodecBuilder frameCodecBuilder, Http2Settings initi
frameWriter = Http2TestUtil.mockedFrameWriter();

frameCodec = frameCodecBuilder.frameWriter(frameWriter).frameLogger(new Http2FrameLogger(LogLevel.TRACE))
.initialSettings(initialRemoteSettings).gracefulShutdownTimeoutMillis(-1).build();
.initialSettings(initialRemoteSettings).build();
inboundHandler = new LastInboundHandler();

channel = new EmbeddedChannel();
Expand Down Expand Up @@ -323,15 +323,15 @@ public void sendGoAway() throws Exception {
ByteBuf debugData = bb("debug");
ByteBuf expected = debugData.copy();

Http2GoAwayFrame goAwayFrame = new DefaultHttp2GoAwayFrame(NO_ERROR.code(), debugData);
Http2GoAwayFrame goAwayFrame = new DefaultHttp2GoAwayFrame(NO_ERROR.code(),
debugData.retainedDuplicate());
goAwayFrame.setExtraStreamIds(2);

channel.writeOutbound(goAwayFrame);
verify(frameWriter).writeGoAway(eqFrameCodecCtx(), eq(7),
eq(NO_ERROR.code()), eq(expected), anyChannelPromise());
assertEquals(1, debugData.refCnt());
assertEquals(State.OPEN, stream.state());
assertTrue(channel.isActive());
assertEquals(State.CLOSED, stream.state());
assertFalse(channel.isActive());
expected.release();
debugData.release();
}
Expand Down Expand Up @@ -386,16 +386,17 @@ public void goAwayLastStreamIdOverflowed() throws Exception {
assertEquals(State.OPEN, stream.state());

ByteBuf debugData = bb("debug");
Http2GoAwayFrame goAwayFrame = new DefaultHttp2GoAwayFrame(NO_ERROR.code(), debugData.slice());
Http2GoAwayFrame goAwayFrame = new DefaultHttp2GoAwayFrame(NO_ERROR.code(),
debugData.retainedDuplicate());
goAwayFrame.setExtraStreamIds(Integer.MAX_VALUE);

channel.writeOutbound(goAwayFrame);
// When the last stream id computation overflows, the last stream id should just be set to 2^31 - 1.
verify(frameWriter).writeGoAway(eqFrameCodecCtx(), eq(Integer.MAX_VALUE),
eq(NO_ERROR.code()), eq(debugData), anyChannelPromise());
assertEquals(1, debugData.refCnt());
assertEquals(State.OPEN, stream.state());
assertTrue(channel.isActive());
debugData.release();
assertEquals(State.CLOSED, stream.state());
assertFalse(channel.isActive());
}

@Test
Expand Down

0 comments on commit 2ffd428

Please sign in to comment.