Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emulate AbstractManagedChannelImplBuilder maxInboundMessageSize(int) #8597

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions core/src/main/java/io/grpc/internal/ManagedChannelImplBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,28 @@ int getDefaultPort() {
return channelBuilderDefaultPortProvider.getDefaultPort();
}

// Remove this emulation when we delete AbstractManagedChannelImplBuilder
private AbstractManagedChannelImplBuilderEmulator abstractManagedChannelImplBuilderEmulator;

public interface AbstractManagedChannelImplBuilderEmulator {
void maxInboundMessageSize(int max);
}

public void emulateAbstractManagedChannelImplBuilder(
AbstractManagedChannelImplBuilderEmulator abstractManagedChannelImplBuilderEmulator) {
this.abstractManagedChannelImplBuilderEmulator = abstractManagedChannelImplBuilderEmulator;
}

@Override
public ManagedChannelImplBuilder maxInboundMessageSize(int max) {
if (abstractManagedChannelImplBuilderEmulator != null) {
abstractManagedChannelImplBuilderEmulator.maxInboundMessageSize(max);
return this;
} else {
return super.maxInboundMessageSize(max); // noop
}
}

private static class DirectAddressNameResolverFactory extends NameResolver.Factory {
final SocketAddress address;
final String authority;
Expand Down
11 changes: 11 additions & 0 deletions netty/src/main/java/io/grpc/netty/NettyChannelBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ public int getDefaultPort() {
managedChannelImplBuilder = new ManagedChannelImplBuilder(target,
new NettyChannelTransportFactoryBuilder(),
new NettyChannelDefaultPortProvider());
managedChannelImplBuilder.emulateAbstractManagedChannelImplBuilder(new OldBuilderEmulator());
this.freezeProtocolNegotiatorFactory = false;
}

Expand All @@ -211,6 +212,7 @@ public int getDefaultPort() {
target, channelCreds, callCreds,
new NettyChannelTransportFactoryBuilder(),
new NettyChannelDefaultPortProvider());
managedChannelImplBuilder.emulateAbstractManagedChannelImplBuilder(new OldBuilderEmulator());
this.protocolNegotiatorFactory = checkNotNull(negotiator, "negotiator");
this.freezeProtocolNegotiatorFactory = true;
}
Expand All @@ -221,6 +223,7 @@ public int getDefaultPort() {
getAuthorityFromAddress(address),
new NettyChannelTransportFactoryBuilder(),
new NettyChannelDefaultPortProvider());
managedChannelImplBuilder.emulateAbstractManagedChannelImplBuilder(new OldBuilderEmulator());
this.freezeProtocolNegotiatorFactory = false;
}

Expand All @@ -232,6 +235,7 @@ public int getDefaultPort() {
channelCreds, callCreds,
new NettyChannelTransportFactoryBuilder(),
new NettyChannelDefaultPortProvider());
managedChannelImplBuilder.emulateAbstractManagedChannelImplBuilder(new OldBuilderEmulator());
this.protocolNegotiatorFactory = checkNotNull(negotiator, "negotiator");
this.freezeProtocolNegotiatorFactory = true;
}
Expand Down Expand Up @@ -764,4 +768,11 @@ public void close() {
groupPool.returnObject(group);
}
}

private final class OldBuilderEmulator implements
ManagedChannelImplBuilder.AbstractManagedChannelImplBuilderEmulator {
@Override public void maxInboundMessageSize(int max) {
NettyChannelBuilder.this.maxInboundMessageSize(max);
}
}
}
9 changes: 9 additions & 0 deletions okhttp/src/main/java/io/grpc/okhttp/OkHttpChannelBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ private OkHttpChannelBuilder(String target) {
managedChannelImplBuilder = new ManagedChannelImplBuilder(target,
new OkHttpChannelTransportFactoryBuilder(),
new OkHttpChannelDefaultPortProvider());
managedChannelImplBuilder.emulateAbstractManagedChannelImplBuilder(new OldBuilderEmulator());
this.freezeSecurityConfiguration = false;
}

Expand All @@ -201,6 +202,7 @@ private OkHttpChannelBuilder(String target) {
target, channelCreds, callCreds,
new OkHttpChannelTransportFactoryBuilder(),
new OkHttpChannelDefaultPortProvider());
managedChannelImplBuilder.emulateAbstractManagedChannelImplBuilder(new OldBuilderEmulator());
this.sslSocketFactory = factory;
this.negotiationType = factory == null ? NegotiationType.PLAINTEXT : NegotiationType.TLS;
this.freezeSecurityConfiguration = true;
Expand Down Expand Up @@ -830,4 +832,11 @@ public void close() {
}
}
}

private final class OldBuilderEmulator implements
ManagedChannelImplBuilder.AbstractManagedChannelImplBuilderEmulator {
@Override public void maxInboundMessageSize(int max) {
OkHttpChannelBuilder.this.maxInboundMessageSize(max);
}
}
}