Skip to content

DefaultHttp2Connection.DefaultEndpoint#lastStreamCreated return 0 when the actual stream id is Integer.MAX_VALUE #13805

@DreamLettuce

Description

@DreamLettuce

Expected behavior

when stream id is Integer.MAX_VALUE, DefaultHttp2Connection.DefaultEndpoint#lastStreamCreated is expected to return Integer.MAX_VALUE
image

Actual behavior

  1. DefaultHttp2Connection.DefaultEndpoint#lastStreamCreated return 0
  2. io.netty.handler.codec.http2.StreamBufferingEncoder#isExistingStream return false
  3. StreamBufferingEncoder write data frame failed
image
  1. the further problem is that grpc-java does not handle this write data failure in NettyClientStream
    .this result to the grpc client thread hangs forever is we use grpc blocking stub

Steps to reproduce

add the following test case to io.netty.handler.codec.http2.StreamBufferingEncoderTest

    @Test
    public void testExhaustedStreamId() throws Http2Exception {
        int nextStreamId = Integer.MAX_VALUE - 2;
        testStreamId(nextStreamId);
        nextStreamId = connection.local().incrementAndGetNextStreamId();
        testStreamId(nextStreamId);
    }

    private void testStreamId(int nextStreamId) throws Http2Exception {
        connection.local().createStream(nextStreamId, false);
        ByteBuf data = data();
        ChannelFuture channelFuture = encoder.writeData(ctx, nextStreamId, data, 0, false, newPromise());
        if (channelFuture.cause() != null) {
            channelFuture.cause().printStackTrace();
        }
        assertTrue(channelFuture.cause() == null);
    }
image image

Minimal yet complete reproducer code (or URL to code)

Netty version

any support http2

JVM version (e.g. java -version)

1.8

OS version (e.g. uname -a)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions