Skip to content

Generate test gRPC transport address per application context#50865

Closed
filmi7873 wants to merge 1 commit into
spring-projects:mainfrom
filmi7873:fix-test-grpc-transport-inprocess-name
Closed

Generate test gRPC transport address per application context#50865
filmi7873 wants to merge 1 commit into
spring-projects:mainfrom
filmi7873:fix-test-grpc-transport-inprocess-name

Conversation

@filmi7873

Copy link
Copy Markdown

This updates TestGrpcTransportAutoConfiguration to generate the in-process test gRPC transport address as an application-context bean rather than a static field.

Previously, the generated address was shared for the lifetime of the JVM. When multiple application contexts were created in the same test run, such as with nested tests using different profiles, the second context could attempt to register an in-process gRPC server with the same name and fail with java.io.IOException: name already registered.

The generated address is now context-specific and injected into both the test server factory and test channel factory, so each application context gets a unique address while the server and client within the same context still share one.

A regression test has been added to start two contexts while the first remains active.

Fixes #50860

Tests:

  • ./gradlew :module:spring-boot-grpc-test:format
  • ./gradlew :module:spring-boot-grpc-test:test --tests "*TestGrpcTransportAutoConfigurationTests"
  • ./gradlew :module:spring-boot-grpc-test:test --tests "*Grpc*"

Signed-off-by: filmi7873 <ilmi.5@osu.edu>
@filmi7873
filmi7873 force-pushed the fix-test-grpc-transport-inprocess-name branch from 7921574 to 73fefdd Compare June 25, 2026 18:12
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 25, 2026
@snicoll

snicoll commented Jul 23, 2026

Copy link
Copy Markdown
Member

Thanks for the PR but I don't think this is the right way to address this. This would create a new server irrespective of whether it is needed. I think the auto-configuration and its slice does not integrate to the context as they should.

@snicoll snicoll closed this Jul 23, 2026
@snicoll snicoll added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: declined A suggestion or change that we don't feel we should currently apply

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AutoConfigureTestGrpcTransport does not participate in the test context's key and tries to start the same in-process server multiple times

3 participants