Skip to content

Commit

Permalink
core: copy the SchemaDescriptor when rebuilding descriptor
Browse files Browse the repository at this point in the history
useMarshalledMessages works by duplicating a ServerServiceDefinition while replacing just the marshallers. It currently does not copy over the SchemaDescriptors, which breaks at least the ProtoReflectionService.
  • Loading branch information
herbyderby committed Mar 23, 2020
1 parent 8d4240f commit 3c98d93
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions api/src/main/java/io/grpc/ServerInterceptors.java
Expand Up @@ -187,13 +187,15 @@ public static <T> ServerServiceDefinition useMarshalledMessages(
wrappedMethods.add(wrapMethod(definition, wrappedMethodDescriptor));
}
// Build the new service descriptor
final ServerServiceDefinition.Builder serviceBuilder = ServerServiceDefinition
.builder(new ServiceDescriptor(serviceDef.getServiceDescriptor().getName(),
wrappedDescriptors));
// Create the new service definiton.
for (ServerMethodDefinition<?, ?> definition : wrappedMethods) {
serviceBuilder.addMethod(definition);
final ServiceDescriptor.Builder serviceDescriptorBuilder =
ServiceDescriptor.newBuilder(serviceDef.getServiceDescriptor().getName())
.setSchemaDescriptor(serviceDef.getServiceDescriptor().getSchemaDescriptor());
for (MethodDescriptor<?, ?> wrappedDescriptor : wrappedDescriptors) {
serviceDescriptorBuilder.addMethod(wrappedDescriptor);
}
// Create the new service definition.
final ServerServiceDefinition.Builder serviceBuilder =
ServerServiceDefinition.builder(serviceDescriptorBuilder.build());
return serviceBuilder.build();
}

Expand Down

0 comments on commit 3c98d93

Please sign in to comment.