grpc-web icon indicating copy to clipboard operation
grpc-web copied to clipboard

RequestHandler does not account for java_package_name

Open lorefnon opened this issue 4 years ago • 1 comments

In proto definition we can specify java_package which can be different from the protobuf package name.

However getClassObject method in RequestHandler just suffixes Grpc into the qualified protobuf class name when attempting to find a class.

As a result, if the java_package is different from protobuf package name, then all requests fail with class not found error.

This method should ideally be aware of the java_package field specified in protobuf.

lorefnon avatar Oct 10 '21 10:10 lorefnon

Same here. I fixed this for my purposes with a ServiceToClassMapping helper class (see here https://github.com/TimmFitschen/grpc-web/commit/d24991f21c40e2971a8aa4dbb90731ee9cebc539)

If desired, I can prepare a pull request. But I guess you people might have something else in mind for this problem. So I won't pollute your pull-requests and spare me some time until you give me a go.

Anyone else, feel free to use it (under Apache 2.0 of course). Just add

io.grpcweb.ServiceToClassMapping.put(org.example.MyServiceGrpc.SERVICE_NAME, org.example.MyServiceGrpc.class);

(for every service class) before you start the proxy.

TimmFitschen avatar Oct 22 '21 13:10 TimmFitschen