We just found out bindService() on the generated server interface is 
supposed to be "final", but is currently not.

For example:

public abstract class RouteGuideImplBase {
  // Empty implementations, to be overridden by the application
  public StreamObserver routeSingle(StreamObserver) {
    failWithUnimplemented();
  }
  public StreamObserver routeMultiple(StreamObserver) {
    failWithUnimplemented();
  }

  // Glue code called by gRPC server to register the service.
  // Not supposed to be overridden.
  public *bindService*() {
    ...
  }
}

*Why is it an issue*

The non-final bindService() adds difficulty for users who want to mock the 
server interface in their tests. Mockito by default overrides all non-final 
methods with its no-op and null-returning impl. When a Mockito user creates 
a mock for RouteGuideImplBase, it can't be correctly registered to the 
server. It can be worked around by explicitly telling Mockito to use the 
original bindService(), but it's still a friction in the user experience.

*What should we do*

bindService() should have been defined as "final" in the first place. It 
was an oversight that we didn't make it so.  This should be considered as a 
bug (filed as #2552 <https://github.com/grpc/grpc-java/issues/2552>) and be 
fixed.

We will make the change in master, which will be in 1.1.0.

*Risk*

This is technically an incompatible API change. Anyone overrides 
bindService() on the generated interface will be broken. However, I don't 
find anyone doing so in google3, or any legitimate reason for it in 
general. The chance of breaking anyone should very low. *If you have any 
concerns, feel free to reply to this thread.*

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/459fd639-27a9-4dca-9df3-86d8294fb37e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to