Home / Function/ initializeNewStream() — netty Function Reference

initializeNewStream() — netty Function Reference

Architecture documentation for the initializeNewStream() function in Http2FrameCodec.java from the netty codebase.

Function java Buffer Allocators calls 2 called by 2

Entity Profile

Dependency Diagram

graph TD
  ef6e1c55_359c_e3f4_48fa_592fc9340049["initializeNewStream()"]
  ba77a225_4637_fe77_ee1f_54a9774ca7f8["Http2FrameCodec"]
  ef6e1c55_359c_e3f4_48fa_592fc9340049 -->|defined in| ba77a225_4637_fe77_ee1f_54a9774ca7f8
  396fd1f5_befd_2a62_19e3_268bf7458c0e["writeHeadersFrame()"]
  396fd1f5_befd_2a62_19e3_268bf7458c0e -->|calls| ef6e1c55_359c_e3f4_48fa_592fc9340049
  6e205303_bd86_2dc6_ac06_0635c7f76774["writePushPromise()"]
  6e205303_bd86_2dc6_ac06_0635c7f76774 -->|calls| ef6e1c55_359c_e3f4_48fa_592fc9340049
  c3697987_0f51_1bd9_b480_661a55bd7f7a["onHttp2Frame()"]
  ef6e1c55_359c_e3f4_48fa_592fc9340049 -->|calls| c3697987_0f51_1bd9_b480_661a55bd7f7a
  a74bf7b5_d200_c820_68fa_528885471d31["onStreamAdded()"]
  ef6e1c55_359c_e3f4_48fa_592fc9340049 -->|calls| a74bf7b5_d200_c820_68fa_528885471d31
  style ef6e1c55_359c_e3f4_48fa_592fc9340049 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http2/src/main/java/io/netty/handler/codec/http2/Http2FrameCodec.java lines 453–480

    private boolean initializeNewStream(ChannelHandlerContext ctx, DefaultHttp2FrameStream http2FrameStream,
                                        ChannelPromise promise) {
        final Http2Connection connection = connection();
        final int streamId = connection.local().incrementAndGetNextStreamId();
        if (streamId < 0) {
            promise.setFailure(new Http2NoMoreStreamIdsException());

            // Simulate a GOAWAY being received due to stream exhaustion on this connection. We use the maximum
            // valid stream ID for the current peer.
            onHttp2Frame(ctx, new DefaultHttp2GoAwayFrame(connection.isServer() ? Integer.MAX_VALUE :
                    Integer.MAX_VALUE - 1, NO_ERROR.code(),
                    writeAscii(ctx.alloc(), "Stream IDs exhausted on local stream creation")));

            return false;
        }
        http2FrameStream.id = streamId;

        // Use a Map to store all pending streams as we may have multiple. This is needed as if we would store the
        // stream in a field directly we may override the stored field before onStreamAdded(...) was called
        // and so not correctly set the property for the buffered stream.
        //
        // See https://github.com/netty/netty/issues/8692
        Object old = frameStreamToInitializeMap.put(streamId, http2FrameStream);

        // We should not re-use ids.
        assert old == null;
        return true;
    }

Domain

Subdomains

Frequently Asked Questions

What does initializeNewStream() do?
initializeNewStream() is a function in the netty codebase, defined in codec-http2/src/main/java/io/netty/handler/codec/http2/Http2FrameCodec.java.
Where is initializeNewStream() defined?
initializeNewStream() is defined in codec-http2/src/main/java/io/netty/handler/codec/http2/Http2FrameCodec.java at line 453.
What does initializeNewStream() call?
initializeNewStream() calls 2 function(s): onHttp2Frame, onStreamAdded.
What calls initializeNewStream()?
initializeNewStream() is called by 2 function(s): writeHeadersFrame, writePushPromise.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free