Could not add interceptor(s) to `ProtoReflectionService`
What did you do?
Add interceptor(s) to ProtoReflectionService.
What did you expect to see?
ProtoReflectionService works with interceptor(s).
What did you see instead?
Got a NullPointerException or compilation error.
Problem
I ask a question on Gitter. https://gitter.im/grpc/grpc?at=59b9090bcfeed2eb65033bad and I have got a reply from @e.jona86. https://gitter.im/grpc/grpc?at=59b9a7f9c101bc4e3ac3404a I think it is not easy to fix. So I report an issue.
ProtoReflectionService needs a reference to Server via notifyOnBuild but it could not, because an intercepted service is an instance of ServerServiceDefinition.
I think it is consisting some problems (may not a bug or may not a problem) as below.
ServerInterceptors#interceptbinds a service and returnsServerServiceDefinition.ServerBuilder#addServicedoesn't addServerServiceDefinitiontonotifyOnBuildList.ServerServiceDefinitiondoesn't implementInternalNotifyOnBuild.
Therefore, I could not add interceptor(s) to ProtoReflectionService.
@ericgribkoff, were we aware of this limitation during the design?
@ejona86 No, I don't think so. This was an oversight on my part. I'll look into getting the mechanism working with server interceptors.
As I mentioned in #3449, we could add a field of a method to run to ServerServiceDefinition as a replacement for InternalNotifyOnBuild.
Note: you may be able to use ServerBuilder.intercept() as a workaround. As long as you're okay with the interceptor applying to all services, that would work.
Thank you for your reply, it works. But I want to add interceptor(s) to each services. I'm waiting for resolving this issue because it seems to be hard to resolve for me...