Skip to content

Commit

Permalink
fix: logger.warn instead of ISE on transcoding options for non-unary …
Browse files Browse the repository at this point in the history
…gRPC (#5829)

Motivation:

- #5828
- When an rpc method has transcoding options, the server won't start up.

Modifications:

- Warn and skip the method instead of preventing server startup.

Result:

- Closes #5828
- Server can start if a gRPC non-unary rpc is configured to have
transcoding options.
  • Loading branch information
Dogacel authored and ikhoon committed Jul 26, 2024
1 parent a3d1cc8 commit 9025934
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,12 @@ static GrpcService of(GrpcService delegate, HttpJsonTranscodingOptions httpJsonT

final HttpRule httpRule = methodOptions.getExtension(AnnotationsProto.http);

checkArgument(methodDefinition.getMethodDescriptor().getType() == MethodType.UNARY,
"Only unary methods can be configured with an HTTP/JSON endpoint: " +
"method=%s, httpRule=%s",
methodDefinition.getMethodDescriptor().getFullMethodName(), httpRule);
if (methodDefinition.getMethodDescriptor().getType() != MethodType.UNARY) {
logger.warn("Only unary methods can be configured with an HTTP/JSON endpoint: " +
"method={}, httpRule={}",
methodDefinition.getMethodDescriptor().getFullMethodName(), httpRule);
continue;
}

@Nullable
final Entry<Route, List<PathVariable>> routeAndVariables = toRouteAndPathVariables(httpRule);
Expand Down
6 changes: 6 additions & 0 deletions grpc/src/test/proto/testing/grpc/transcoding.proto
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@ service HttpJsonTranscodingTestService {
}
};
}

rpc EchoBidirectionalStream(stream Message) returns (stream Message) {
option (google.api.http) = {
post: "/v1/echo/bidirectional_stream"
};
}
}

message GetMessageRequestV1 {
Expand Down

0 comments on commit 9025934

Please sign in to comment.