|
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,31 @@ 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 | + In refactoring described in #7211, the implementation of #maxInboundMessageSize(int) |
| 177 | + (and its corresponding field) was pulled down from internal AbstractManagedChannelImplBuilder |
| 178 | + to concrete classes that actually enforce this setting. For the same reason, it wasn't ported |
| 179 | + to ManagedChannelImplBuilder (the #delegate()). |
| 180 | +
|
| 181 | + Then AbstractManagedChannelImplBuilder was brought back to fix ABI backward compatibility, |
| 182 | + and temporarily turned into a ForwardingChannelBuilder, ref PR #7564. Eventually it will |
| 183 | + be deleted, after a period with "bridge" ABI solution introduced in #7834. |
| 184 | +
|
| 185 | + However, restoring AbstractManagedChannelImplBuilder unintentionally made ABI of |
| 186 | + #maxInboundMessageSize(int) implemented by the concrete classes backward incompatible: |
| 187 | + pre-refactoring builds expect it to be a method of AbstractManagedChannelImplBuilder, |
| 188 | + and not concrete classes, ref #8313. |
| 189 | +
|
| 190 | + The end goal is to keep #maxInboundMessageSize(int) only in concrete classes that enforce it. |
| 191 | + To fix method's ABI, we temporary reintroduce it to the original layer it was removed from: |
| 192 | + AbstractManagedChannelImplBuilder. This class' only intention is to provide short-term |
| 193 | + ABI compatibility. Once we move forward with dropping the ABI, both fixes are no longer |
| 194 | + necessary, and both will perish with removing AbstractManagedChannelImplBuilder. |
| 195 | + */ |
| 196 | + Preconditions.checkArgument(max >= 0, "negative max"); |
| 197 | + maxInboundMessageSize = max; |
165 | 198 | return thisT();
|
166 | 199 | }
|
167 | 200 |
|
|
0 commit comments