createStreamAfterReceiveGoAwayShouldNotSendGoAway() — netty Function Reference
Architecture documentation for the createStreamAfterReceiveGoAwayShouldNotSendGoAway() function in Http2ConnectionRoundtripTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 8fd47c86_20bd_a9ab_40d0_3a52f1e6eca7["createStreamAfterReceiveGoAwayShouldNotSendGoAway()"] 0d6189e8_c033_39ff_d087_9019351440fe["Http2ConnectionRoundtripTest"] 8fd47c86_20bd_a9ab_40d0_3a52f1e6eca7 -->|defined in| 0d6189e8_c033_39ff_d087_9019351440fe 1dd685b8_9b56_5b35_70ca_7f2bf9016254["bootstrapEnv()"] 8fd47c86_20bd_a9ab_40d0_3a52f1e6eca7 -->|calls| 1dd685b8_9b56_5b35_70ca_7f2bf9016254 f8a98f5a_5b4f_5e46_24a0_b03b1f68c64a["setClientGracefulShutdownTime()"] 8fd47c86_20bd_a9ab_40d0_3a52f1e6eca7 -->|calls| f8a98f5a_5b4f_5e46_24a0_b03b1f68c64a da672232_873c_287f_a7ac_aff79739090a["setServerGracefulShutdownTime()"] 8fd47c86_20bd_a9ab_40d0_3a52f1e6eca7 -->|calls| da672232_873c_287f_a7ac_aff79739090a style 8fd47c86_20bd_a9ab_40d0_3a52f1e6eca7 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ConnectionRoundtripTest.java lines 837–913
@Test
public void createStreamAfterReceiveGoAwayShouldNotSendGoAway() throws Exception {
final CountDownLatch clientGoAwayLatch = new CountDownLatch(1);
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
clientGoAwayLatch.countDown();
return null;
}
}).when(clientListener).onGoAwayRead(any(ChannelHandlerContext.class), anyInt(), anyLong(), any(ByteBuf.class));
bootstrapEnv(1, 1, 2, 1, 1);
// We want both sides to do graceful shutdown during the test.
setClientGracefulShutdownTime(10000);
setServerGracefulShutdownTime(10000);
// Create a single stream by sending a HEADERS frame to the server.
final Http2Headers headers = dummyHeaders();
runInChannel(clientChannel, new Http2Runnable() {
@Override
public void run() throws Http2Exception {
http2Client.encoder().writeHeaders(ctx(), 3, headers, 0, (short) 16, false, 0,
false, newPromise());
http2Client.flush(ctx());
}
});
assertTrue(serverSettingsAckLatch.await(DEFAULT_AWAIT_TIMEOUT_SECONDS, SECONDS));
// Server has received the headers, so the stream is open
assertTrue(requestLatch.await(DEFAULT_AWAIT_TIMEOUT_SECONDS, SECONDS));
runInChannel(serverChannel, new Http2Runnable() {
@Override
public void run() throws Http2Exception {
http2Server.encoder().writeGoAway(serverCtx(), 3, NO_ERROR.code(), EMPTY_BUFFER, serverNewPromise());
http2Server.flush(serverCtx());
}
});
// wait for the client to receive the GO_AWAY.
assertTrue(clientGoAwayLatch.await(DEFAULT_AWAIT_TIMEOUT_SECONDS, SECONDS));
verify(clientListener).onGoAwayRead(any(ChannelHandlerContext.class), eq(3), eq(NO_ERROR.code()),
any(ByteBuf.class));
final AtomicReference<ChannelFuture> clientWriteAfterGoAwayFutureRef = new AtomicReference<ChannelFuture>();
final CountDownLatch clientWriteAfterGoAwayLatch = new CountDownLatch(1);
runInChannel(clientChannel, new Http2Runnable() {
@Override
public void run() throws Http2Exception {
ChannelFuture f = http2Client.encoder().writeHeaders(ctx(), 5, headers, 0, (short) 16, false, 0,
true, newPromise());
clientWriteAfterGoAwayFutureRef.set(f);
http2Client.flush(ctx());
f.addListener(future -> clientWriteAfterGoAwayLatch.countDown());
}
});
// Wait for the client's write operation to complete.
assertTrue(clientWriteAfterGoAwayLatch.await(DEFAULT_AWAIT_TIMEOUT_SECONDS, SECONDS));
ChannelFuture clientWriteAfterGoAwayFuture = clientWriteAfterGoAwayFutureRef.get();
assertNotNull(clientWriteAfterGoAwayFuture);
Throwable clientCause = clientWriteAfterGoAwayFuture.cause();
assertInstanceOf(Http2Exception.StreamException.class, clientCause);
assertEquals(Http2Error.REFUSED_STREAM.code(), ((Http2Exception.StreamException) clientCause).error().code());
// Wait for the server to receive a GO_AWAY, but this is expected to timeout!
assertFalse(goAwayLatch.await(1, SECONDS));
verify(serverListener, never()).onGoAwayRead(any(ChannelHandlerContext.class), anyInt(), anyLong(),
any(ByteBuf.class));
// Shutdown shouldn't wait for the server to close streams
setClientGracefulShutdownTime(0);
setServerGracefulShutdownTime(0);
}
Domain
Subdomains
Source
Frequently Asked Questions
What does createStreamAfterReceiveGoAwayShouldNotSendGoAway() do?
createStreamAfterReceiveGoAwayShouldNotSendGoAway() is a function in the netty codebase, defined in codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ConnectionRoundtripTest.java.
Where is createStreamAfterReceiveGoAwayShouldNotSendGoAway() defined?
createStreamAfterReceiveGoAwayShouldNotSendGoAway() is defined in codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ConnectionRoundtripTest.java at line 837.
What does createStreamAfterReceiveGoAwayShouldNotSendGoAway() call?
createStreamAfterReceiveGoAwayShouldNotSendGoAway() calls 3 function(s): bootstrapEnv, setClientGracefulShutdownTime, setServerGracefulShutdownTime.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free