Skip to content
This repository was archived by the owner on Sep 26, 2023. It is now read-only.
Merged
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
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ apply plugin: 'io.codearte.nexus-staging'
project.version = "1.35.2-SNAPSHOT" // {x-version-update:gax:current}

ext {
grpcVersion = '1.16.1'
grpcVersion = '1.17.1'
commonProtosVersion = '1.12.0'
authVersion = '0.12.0'
// Project names not used for release
Expand Down Expand Up @@ -116,6 +116,7 @@ subprojects {
grpcAuth: "io.grpc:grpc-auth:${grpcVersion}",
grpcProtobuf: "io.grpc:grpc-protobuf:${grpcVersion}",
grpcNetty: "io.grpc:grpc-netty-shaded:${grpcVersion}",
grpcAlts: "io.grpc:grpc-alts:${grpcVersion}",
gson: "com.google.code.gson:gson:2.7",
guava: 'com.google.guava:guava:26.0-android',
jsr305: 'com.google.code.findbugs:jsr305:3.0.2',
Expand Down
3 changes: 2 additions & 1 deletion gax-grpc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ dependencies {
libraries.authCredentials,
libraries.commonProtos,
libraries.apiCommon,
libraries.grpcNetty
libraries.grpcNetty,
libraries.grpcAlts

compileOnly libraries.autovalue

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
import com.google.common.collect.ImmutableList;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import io.grpc.alts.GoogleDefaultChannelBuilder;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -184,49 +184,16 @@ private ManagedChannel createSingleChannel() throws IOException {
int port = Integer.parseInt(endpoint.substring(colon + 1));
String serviceAddress = endpoint.substring(0, colon);

// TODO(hzyi): Change to ManagedChannelBuilder directly when
// https://github.com/grpc/grpc-java/issues/4050 is resolved.
ManagedChannelBuilder builder;
ManagedChannelBuilder builder =
GoogleDefaultChannelBuilder.forAddress(serviceAddress, port)
.intercept(headerInterceptor)
.intercept(metadataHandlerInterceptor)
.userAgent(headerInterceptor.getUserAgentHeader())
.executor(executor);

if (maxInboundMetadataSize != null) {
Class<?> nettyChannelBuilderClass;
try {
nettyChannelBuilderClass =
Class.forName("io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder");
} catch (ClassNotFoundException e) {
try {
nettyChannelBuilderClass = Class.forName("io.grpc.netty.NettyChannelBuilder");
} catch (ClassNotFoundException ex) {
throw new RuntimeException(
"Unable to create the channel because neither"
+ " \"io.grpc.netty.NettyChannelBuilder\" nor"
+ " \"io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder\" is found.");
}
}
try {
Object object =
nettyChannelBuilderClass
.getMethod("forAddress", String.class, int.class)
.invoke(null, serviceAddress, port);
object =
nettyChannelBuilderClass
.getMethod("maxHeaderListSize", int.class)
.invoke(object, maxInboundMetadataSize);
builder = (ManagedChannelBuilder) object;
} catch (NoSuchMethodException
| IllegalAccessException
| IllegalArgumentException
| InvocationTargetException e) {
throw new RuntimeException(
"Unable to set maxHeaderListSize due to exception: " + e.getMessage());
}
} else {
builder = ManagedChannelBuilder.forAddress(serviceAddress, port);
builder.maxInboundMetadataSize(maxInboundMetadataSize);
}
builder
.intercept(headerInterceptor)
.intercept(metadataHandlerInterceptor)
.userAgent(headerInterceptor.getUserAgentHeader())
.executor(executor);
if (maxInboundMessageSize != null) {
builder.maxInboundMessageSize(maxInboundMessageSize);
}
Expand Down