|
17 | 17 | package io.grpc.internal;
|
18 | 18 |
|
19 | 19 | import com.google.common.base.MoreObjects;
|
| 20 | +import com.google.common.base.Preconditions; |
20 | 21 | import com.google.errorprone.annotations.DoNotCall;
|
21 | 22 | import io.grpc.BinaryLog;
|
22 | 23 | import io.grpc.ClientInterceptor;
|
|
42 | 43 | public abstract class AbstractManagedChannelImplBuilder
|
43 | 44 | <T extends AbstractManagedChannelImplBuilder<T>> extends ManagedChannelBuilder<T> {
|
44 | 45 |
|
| 46 | + /** |
| 47 | + * Added for ABI compatibility. |
| 48 | + * |
| 49 | + * <p>See details in {@link #maxInboundMessageSize(int)}. |
| 50 | + * TODO(sergiitk): move back to concrete classes as a private field, when this class is removed. |
| 51 | + */ |
| 52 | + protected int maxInboundMessageSize = GrpcUtil.DEFAULT_MAX_MESSAGE_SIZE; |
| 53 | + |
45 | 54 | /**
|
46 | 55 | * The default constructor.
|
47 | 56 | */
|
@@ -161,7 +170,32 @@ public T idleTimeout(long value, TimeUnit unit) {
|
161 | 170 |
|
162 | 171 | @Override
|
163 | 172 | public T maxInboundMessageSize(int max) {
|
164 |
| - delegate().maxInboundMessageSize(max); |
| 173 | + /* |
| 174 | + Why this method is not delegating, as the rest of the methods? |
| 175 | +
|
| 176 | + As part of refactoring described in issue #7211, the implementation of this method, |
| 177 | + and its corresponding field was pulled down from internal AbstractManagedChannelImplBuilder |
| 178 | + to concrete classes that actually enforce this setting. That's the right place for |
| 179 | + method's implementation, so it wasn't ported to ManagedChannelImplBuilder too. |
| 180 | +
|
| 181 | + Then AbstractManagedChannelImplBuilder was brought to fix ABI backward compatibility, |
| 182 | + and temporarily turned into a ForwardingChannelBuilder, see PR #7564. Eventually it will |
| 183 | + be deleted, after a period with "bridge" solution added in #7834. |
| 184 | +
|
| 185 | + However, this bringing AbstractManagedChannelImplBuilder back fix unintentionally |
| 186 | + made this method's ABI backward incompatible: pre-refactoring builds expect |
| 187 | + maxInboundMessageSize() to be a method of AbstractManagedChannelImplBuilder, and not |
| 188 | + concrete classes, see https://gist.github.com/sergiitk/39583f20906df1813f5e170317a35dc4#v1322. |
| 189 | + This problem was caught in #8313. |
| 190 | +
|
| 191 | + Since the end goal is to keep only this method in concrete classes the need it, |
| 192 | + to fix its ABI issue, we temporary reintroduce it to the original layer it was removed from, |
| 193 | + AbstractManagedChannelImplBuilder. This class is also temporary, and its only intention |
| 194 | + is a ABI compatibility. Once we move forward with dropping ABI compatibility (with #7834), |
| 195 | + this fix is also no longer necessary, and will go away with AbstractManagedChannelImplBuilder. |
| 196 | + */ |
| 197 | + Preconditions.checkArgument(max >= 0, "negative max"); |
| 198 | + maxInboundMessageSize = max; |
165 | 199 | return thisT();
|
166 | 200 | }
|
167 | 201 |
|
|
0 commit comments