diff --git a/samples/grpc-server/src/test/java/org/springframework/grpc/sample/GrpcServerIntegrationTests.java b/samples/grpc-server/src/test/java/org/springframework/grpc/sample/GrpcServerIntegrationTests.java index 8daea1c..17c7dc6 100644 --- a/samples/grpc-server/src/test/java/org/springframework/grpc/sample/GrpcServerIntegrationTests.java +++ b/samples/grpc-server/src/test/java/org/springframework/grpc/sample/GrpcServerIntegrationTests.java @@ -338,6 +338,23 @@ class GrpcServerIntegrationTests { } + @Nested + @SpringBootTest(properties = { "spring.grpc.server.inprocess.name=foo", "spring.grpc.server.host=0.0.0.0", + "spring.grpc.server.port=0" }) + class ServerWithRegularAndInProcessChannelsAndFactories { + + @Test + void servesResponseToNonInProcessClient(@Autowired GrpcChannelFactory channels, @LocalGrpcPort int port) { + assertThatResponseIsServedToChannel(channels.createChannel("0.0.0.0:" + port)); + } + + @Test + void servesResponseToInProcessClient(@Autowired GrpcChannelFactory channels) { + assertThatResponseIsServedToChannel(channels.createChannel("in-process:foo")); + } + + } + private void assertThatResponseIsServedToChannel(ManagedChannel clientChannel) { SimpleGrpc.SimpleBlockingStub client = SimpleGrpc.newBlockingStub(clientChannel); HelloReply response = client.sayHello(HelloRequest.newBuilder().setName("Alien").build()); diff --git a/spring-grpc-core/src/main/java/org/springframework/grpc/server/lifecycle/GrpcServerLifecycle.java b/spring-grpc-core/src/main/java/org/springframework/grpc/server/lifecycle/GrpcServerLifecycle.java index 47a3be5..0840315 100644 --- a/spring-grpc-core/src/main/java/org/springframework/grpc/server/lifecycle/GrpcServerLifecycle.java +++ b/spring-grpc-core/src/main/java/org/springframework/grpc/server/lifecycle/GrpcServerLifecycle.java @@ -107,6 +107,14 @@ public class GrpcServerLifecycle implements SmartLifecycle { return this.server == null ? 0 : this.server.getPort(); } + /** + * Gets the server factory used to create the server. + * @return the server factory to create the server + */ + public GrpcServerFactory getFactory() { + return this.factory; + } + /** * Creates and starts the grpc server. * @throws IOException If the server is unable to bind the port. diff --git a/spring-grpc-spring-boot-autoconfigure/src/main/java/org/springframework/grpc/autoconfigure/client/ClientPropertiesChannelBuilderCustomizer.java b/spring-grpc-spring-boot-autoconfigure/src/main/java/org/springframework/grpc/autoconfigure/client/ClientPropertiesChannelBuilderCustomizer.java index 18a887a..2a7acbe 100644 --- a/spring-grpc-spring-boot-autoconfigure/src/main/java/org/springframework/grpc/autoconfigure/client/ClientPropertiesChannelBuilderCustomizer.java +++ b/spring-grpc-spring-boot-autoconfigure/src/main/java/org/springframework/grpc/autoconfigure/client/ClientPropertiesChannelBuilderCustomizer.java @@ -49,7 +49,7 @@ class ClientPropertiesChannelBuilderCustomizer