Skip to content

Commit

Permalink
core: copy the SchemaDescriptor when rebuilding descriptor (grpc#6851)
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 authored and dfawley committed Jan 15, 2021
1 parent 83f6fdd commit a0eeb9d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions api/src/main/java/io/grpc/ServerInterceptors.java
Expand Up @@ -197,10 +197,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.
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());
for (ServerMethodDefinition<?, ?> definition : wrappedMethods) {
serviceBuilder.addMethod(definition);
}
Expand Down

0 comments on commit a0eeb9d

Please sign in to comment.