• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

grpc / grpc-java / #20514

09 Oct 2026 08:47AM UTC coverage: 89.382% (+0.03%) from 89.35%
#20514

push

github

web-flow
netty: enable AdaptiveCumulator (#13100)

39270 of 43935 relevant lines covered (89.38%)

0.89 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

66.67
/../netty/src/main/java/io/grpc/netty/GrpcHttp2ConnectionHandler.java
1
/*
2
 * Copyright 2016 The gRPC Authors
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16

17
package io.grpc.netty;
18

19
import static com.google.common.base.Preconditions.checkState;
20

21
import io.grpc.Attributes;
22
import io.grpc.ChannelLogger;
23
import io.grpc.Internal;
24
import io.grpc.InternalChannelz;
25
import io.netty.channel.ChannelPromise;
26
import io.netty.handler.codec.AdaptiveCumulator;
27
import io.netty.handler.codec.ByteToMessageDecoder.Cumulator;
28
import io.netty.handler.codec.http2.Http2ConnectionDecoder;
29
import io.netty.handler.codec.http2.Http2ConnectionEncoder;
30
import io.netty.handler.codec.http2.Http2ConnectionHandler;
31
import io.netty.handler.codec.http2.Http2Settings;
32
import javax.annotation.Nullable;
33

34
/**
35
 * gRPC wrapper for {@link Http2ConnectionHandler}.
36
 */
37
@Internal
38
public abstract class GrpcHttp2ConnectionHandler extends Http2ConnectionHandler {
39
  private static final int ADAPTIVE_CUMULATOR_COMPOSE_MIN_SIZE_DEFAULT = 1024;
40
  private static final Cumulator ADAPTIVE_CUMULATOR =
1 ✔
41
      new AdaptiveCumulator(ADAPTIVE_CUMULATOR_COMPOSE_MIN_SIZE_DEFAULT);
42

43
  @Nullable
44
  protected final ChannelPromise channelUnused;
45
  private final ChannelLogger negotiationLogger;
46

47
  @SuppressWarnings("this-escape")
48
  protected GrpcHttp2ConnectionHandler(
49
      ChannelPromise channelUnused,
50
      Http2ConnectionDecoder decoder,
51
      Http2ConnectionEncoder encoder,
52
      Http2Settings initialSettings,
53
      ChannelLogger negotiationLogger) {
54
    super(decoder, encoder, initialSettings);
1 ✔
55
    this.channelUnused = channelUnused;
1 ✔
56
    this.negotiationLogger = negotiationLogger;
1 ✔
57
    setCumulator(ADAPTIVE_CUMULATOR);
1 ✔
58
  }
1 ✔
59

60
  /**
61
   * Same as {@link #handleProtocolNegotiationCompleted(
62
   *   Attributes, io.grpc.InternalChannelz.Security)}
63
   * but with no {@link io.grpc.InternalChannelz.Security}.
64
   *
65
   * @deprecated Use the two argument method instead.
66
   */
67
  @Deprecated
68
  @SuppressWarnings("InlineMeSuggester") // the caller should consider providing securityInfo
69
  public void handleProtocolNegotiationCompleted(Attributes attrs) {
70
    handleProtocolNegotiationCompleted(attrs, /*securityInfo=*/ null);
×
71
  }
×
72

73
  /**
74
   * Triggered on protocol negotiation completion.
75
   *
76
   * <p>It must me called after negotiation is completed but before given handler is added to the
77
   * channel.
78
   *
79
   * @param attrs arbitrary attributes passed after protocol negotiation (eg. SSLSession).
80
   * @param securityInfo informs channelz about the security protocol.
81
   */
82
  public void handleProtocolNegotiationCompleted(
83
      Attributes attrs, InternalChannelz.Security securityInfo) {
84
  }
1 ✔
85

86
  /**
87
   * Returns the channel logger for the given channel context.
88
   */
89
  public ChannelLogger getNegotiationLogger() {
90
    checkState(negotiationLogger != null, "NegotiationLogger must not be null");
1 ✔
91
    return negotiationLogger;
1 ✔
92
  }
93

94
  /**
95
   * Calling this method indicates that the channel will no longer be used.  This method is roughly
96
   * the same as calling {@link #close} on the channel, but leaving the channel alive.  This is
97
   * useful if the channel will soon be deregistered from the executor and used in a non-Netty
98
   * context.
99
   */
100
  @SuppressWarnings("FutureReturnValueIgnored")
101
  public void notifyUnused() {
102
    channelUnused.setSuccess(null);
×
103
  }
×
104

105
  /** Get the attributes of the EquivalentAddressGroup used to create this transport. */
106
  public Attributes getEagAttributes() {
107
    return Attributes.EMPTY;
1 ✔
108
  }
109

110
  /**
111
   * Returns the authority of the server. Only available on the client-side.
112
   *
113
   * @throws UnsupportedOperationException if on server-side
114
   */
115
  public String getAuthority() {
116
    throw new UnsupportedOperationException();
×
117
  }
118
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc