@Test
    void streamEndsBeforeGoAway() throws Exception {
        try (ServerSocket ss = new ServerSocket(0);
             ClientFactory clientFactory = newClientFactory(eventLoop.get())) {

            final int port = ss.getLocalPort();

            final WebClient client = WebClient.builder("h2c://127.0.0.1:" + port)
                                              .factory(clientFactory)
                                              .build();
            final CompletableFuture<AggregatedHttpResponse> future = client.get("/").aggregate();

            try (Socket s = ss.accept()) {

                final InputStream in = s.getInputStream();
                final BufferedOutputStream bos = new BufferedOutputStream(s.getOutputStream());
                handleInitialExchange(in, bos);

                // Read a HEADERS frame.
                assertThat(readFrame(in).getByte(3)).isEqualTo(Http2FrameTypes.HEADERS);

                // Send a HEADERS frame to finish the response followed by a GOAWAY frame.
                bos.write(new byte[] {
                        0x00, 0x00, 0x06, 0x01, 0x25, 0x00, 0x00, 0x00, 0x03,
                        0x00, 0x00, 0x00, 0x00, 0x0f, (byte) 0x88
                });
                bos.write(new byte[] {
                        0x00, 0x00, 0x08, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
                        0x00, 0x00, 0x00, 0x03, // lastStreamId = 3
                        0x00, 0x00, 0x00, 0x00  // errorCode = 0
                });
                bos.flush();

                // Read a GOAWAY frame.
                assertThat(readFrame(in).getByte(3)).isEqualTo(Http2FrameTypes.GO_AWAY);

                // Request should not fail.
                future.join();

                // The connection should be closed by the client because there is no pending request.
                assertThat(in.read()).isEqualTo(-1);
            }
        }
    }
Server sends a GOAWAY frame after finishing all streams.
core/src/test/java/com/linecorp/armeria/client/Http2GoAwayTest.java