mirror of https://github.com/grpc/grpc-java.git
compiler: final bindService() in generated code. (#2553)
So that it won't be overridden by Mockito when it creates a mock for the server interface.
This commit is contained in:
parent
09fd43df4e
commit
1aaf1a989c
|
@ -95,7 +95,7 @@ public class BenchmarkServiceGrpc {
|
|||
return asyncUnimplementedStreamingCall(METHOD_STREAMING_CALL, responseObserver);
|
||||
}
|
||||
|
||||
@java.lang.Override public io.grpc.ServerServiceDefinition bindService() {
|
||||
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
|
||||
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
|
||||
.addMethod(
|
||||
METHOD_UNARY_CALL,
|
||||
|
|
|
@ -141,7 +141,7 @@ public class WorkerServiceGrpc {
|
|||
asyncUnimplementedUnaryCall(METHOD_QUIT_WORKER, responseObserver);
|
||||
}
|
||||
|
||||
@java.lang.Override public io.grpc.ServerServiceDefinition bindService() {
|
||||
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
|
||||
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
|
||||
.addMethod(
|
||||
METHOD_RUN_SERVER,
|
||||
|
|
|
@ -747,7 +747,7 @@ static void PrintStub(
|
|||
p->Print("\n");
|
||||
p->Print(
|
||||
*vars,
|
||||
"@$Override$ public $ServerServiceDefinition$ bindService() {\n");
|
||||
"@$Override$ public final $ServerServiceDefinition$ bindService() {\n");
|
||||
(*vars)["instance"] = "this";
|
||||
PrintBindServiceMethodBody(service, vars, p, generate_nano);
|
||||
p->Print("}\n");
|
||||
|
|
|
@ -164,7 +164,7 @@ public class TestServiceGrpc {
|
|||
return asyncUnimplementedStreamingCall(METHOD_HALF_BIDI_CALL, responseObserver);
|
||||
}
|
||||
|
||||
@java.lang.Override public io.grpc.ServerServiceDefinition bindService() {
|
||||
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
|
||||
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
|
||||
.addMethod(
|
||||
METHOD_UNARY_CALL,
|
||||
|
|
|
@ -164,7 +164,7 @@ public class TestServiceGrpc {
|
|||
return asyncUnimplementedStreamingCall(METHOD_HALF_BIDI_CALL, responseObserver);
|
||||
}
|
||||
|
||||
@java.lang.Override public io.grpc.ServerServiceDefinition bindService() {
|
||||
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
|
||||
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
|
||||
.addMethod(
|
||||
METHOD_UNARY_CALL,
|
||||
|
|
|
@ -242,7 +242,7 @@ public class TestServiceGrpc {
|
|||
return asyncUnimplementedStreamingCall(METHOD_HALF_BIDI_CALL, responseObserver);
|
||||
}
|
||||
|
||||
@java.lang.Override public io.grpc.ServerServiceDefinition bindService() {
|
||||
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
|
||||
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
|
||||
.addMethod(
|
||||
METHOD_UNARY_CALL,
|
||||
|
|
|
@ -33,11 +33,11 @@ package io.grpc.examples.advanced;
|
|||
|
||||
import static io.grpc.stub.ServerCalls.asyncUnaryCall;
|
||||
|
||||
import io.grpc.BindableService;
|
||||
import io.grpc.Server;
|
||||
import io.grpc.ServerBuilder;
|
||||
import io.grpc.ServerServiceDefinition;
|
||||
import io.grpc.examples.helloworld.GreeterGrpc;
|
||||
import io.grpc.examples.helloworld.GreeterGrpc.GreeterImplBase;
|
||||
import io.grpc.examples.helloworld.HelloReply;
|
||||
import io.grpc.examples.helloworld.HelloRequest;
|
||||
import io.grpc.examples.helloworld.HelloWorldServer;
|
||||
|
@ -106,10 +106,9 @@ public class HelloJsonServer {
|
|||
server.blockUntilShutdown();
|
||||
}
|
||||
|
||||
private static class GreeterImpl extends GreeterImplBase {
|
||||
private static class GreeterImpl implements BindableService {
|
||||
|
||||
@Override
|
||||
public void sayHello(HelloRequest req, StreamObserver<HelloReply> responseObserver) {
|
||||
private void sayHello(HelloRequest req, StreamObserver<HelloReply> responseObserver) {
|
||||
HelloReply reply = HelloReply.newBuilder().setMessage("Hello " + req.getName()).build();
|
||||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
|
|
|
@ -74,7 +74,7 @@ public class LoadBalancerGrpc {
|
|||
return asyncUnimplementedStreamingCall(METHOD_BALANCE_LOAD, responseObserver);
|
||||
}
|
||||
|
||||
@java.lang.Override public io.grpc.ServerServiceDefinition bindService() {
|
||||
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
|
||||
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
|
||||
.addMethod(
|
||||
METHOD_BALANCE_LOAD,
|
||||
|
|
|
@ -65,7 +65,6 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -97,7 +96,6 @@ public class CascadingTest {
|
|||
@Before
|
||||
public void setUp() throws Exception {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
Mockito.when(service.bindService()).thenCallRealMethod();
|
||||
// Use a cached thread pool as we need a thread for each blocked call
|
||||
otherWork = Executors.newCachedThreadPool();
|
||||
channel = InProcessChannelBuilder.forName("channel").executor(otherWork).build();
|
||||
|
|
|
@ -71,7 +71,7 @@ public class HealthGrpc {
|
|||
asyncUnimplementedUnaryCall(METHOD_CHECK, responseObserver);
|
||||
}
|
||||
|
||||
@java.lang.Override public io.grpc.ServerServiceDefinition bindService() {
|
||||
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
|
||||
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
|
||||
.addMethod(
|
||||
METHOD_CHECK,
|
||||
|
|
|
@ -75,7 +75,7 @@ public class ServerReflectionGrpc {
|
|||
return asyncUnimplementedStreamingCall(METHOD_SERVER_REFLECTION_INFO, responseObserver);
|
||||
}
|
||||
|
||||
@java.lang.Override public io.grpc.ServerServiceDefinition bindService() {
|
||||
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
|
||||
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
|
||||
.addMethod(
|
||||
METHOD_SERVER_REFLECTION_INFO,
|
||||
|
|
|
@ -71,7 +71,7 @@ public class DynamicServiceGrpc {
|
|||
asyncUnimplementedUnaryCall(METHOD_METHOD, responseObserver);
|
||||
}
|
||||
|
||||
@java.lang.Override public io.grpc.ServerServiceDefinition bindService() {
|
||||
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
|
||||
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
|
||||
.addMethod(
|
||||
METHOD_METHOD,
|
||||
|
|
|
@ -71,7 +71,7 @@ public class ReflectableServiceGrpc {
|
|||
asyncUnimplementedUnaryCall(METHOD_METHOD, responseObserver);
|
||||
}
|
||||
|
||||
@java.lang.Override public io.grpc.ServerServiceDefinition bindService() {
|
||||
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
|
||||
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
|
||||
.addMethod(
|
||||
METHOD_METHOD,
|
||||
|
|
|
@ -94,7 +94,7 @@ public class MetricsServiceGrpc {
|
|||
asyncUnimplementedUnaryCall(METHOD_GET_GAUGE, responseObserver);
|
||||
}
|
||||
|
||||
@java.lang.Override public io.grpc.ServerServiceDefinition bindService() {
|
||||
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
|
||||
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
|
||||
.addMethod(
|
||||
METHOD_GET_ALL_GAUGES,
|
||||
|
|
|
@ -93,7 +93,7 @@ public class ReconnectServiceGrpc {
|
|||
asyncUnimplementedUnaryCall(METHOD_STOP, responseObserver);
|
||||
}
|
||||
|
||||
@java.lang.Override public io.grpc.ServerServiceDefinition bindService() {
|
||||
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
|
||||
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
|
||||
.addMethod(
|
||||
METHOD_START,
|
||||
|
|
|
@ -204,7 +204,7 @@ public class TestServiceGrpc {
|
|||
asyncUnimplementedUnaryCall(METHOD_UNIMPLEMENTED_CALL, responseObserver);
|
||||
}
|
||||
|
||||
@java.lang.Override public io.grpc.ServerServiceDefinition bindService() {
|
||||
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
|
||||
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
|
||||
.addMethod(
|
||||
METHOD_EMPTY_CALL,
|
||||
|
|
|
@ -82,7 +82,7 @@ public class UnimplementedServiceGrpc {
|
|||
asyncUnimplementedUnaryCall(METHOD_UNIMPLEMENTED_CALL, responseObserver);
|
||||
}
|
||||
|
||||
@java.lang.Override public io.grpc.ServerServiceDefinition bindService() {
|
||||
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
|
||||
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
|
||||
.addMethod(
|
||||
METHOD_UNIMPLEMENTED_CALL,
|
||||
|
|
Loading…
Reference in New Issue