Make request/reply auto-configuration excludable (#8); document context propagation (#50)#56
Merged
Conversation
…xt propagation (#50) Issue #8: the per-binding reply-consumer registration lived in an ApplicationContextInitializer registered via spring.factories. Spring applies such initializers to every application context it creates - including sliced tests such as @jsontest - and they cannot be turned off via @ImportAutoConfiguration(exclude = ...) or spring.autoconfigure.exclude. Because the registered reply consumers depend on the RequestReplyServiceImpl bean (which is absent in a slice), the context failed to start. Move the registration into RequestReplyFunctionRegistrar, an ImportBeanDefinitionRegistrar imported by RequestReplyAutoConfiguration, and remove the ApplicationContextInitializer entry from spring.factories. The registration now runs only when the auto-configuration itself is active, so excluding the auto-configuration also disables the reply-consumer registration. Issue #50 (context propagation to every CompletableFuture stage) was already fixed and released in 6.0.2 but was missing from the documentation. Add the 6.0.2 CHANGELOG entry and a README section describing the behaviour. Tests (both verified red before the fix, green after): - RequestReplyAutoConfigurationExclusionTests: the reporter's @jsontest scenario - RequestReplyExcludeAutoConfigurationTests: explicit spring.autoconfigure.exclude Full suite: 87 tests pass.
This was referenced Jun 22, 2026
Closed
There was a problem hiding this comment.
Pull request overview
This PR makes the request/reply auto-configuration properly excludable (especially for sliced tests) by moving reply-consumer registration out of a globally-applied ApplicationContextInitializer and into an auto-config-scoped registrar, and it adds documentation/changelog entries around context propagation behavior.
Changes:
- Replaced the
ApplicationContextInitializer-based function registration with anImportBeanDefinitionRegistrarimported byRequestReplyAutoConfiguration, and removed the initializer entry fromMETA-INF/spring.factories. - Added regression tests covering
@JsonTestslicing and explicit auto-config exclusion. - Added README + CHANGELOG documentation for context propagation and the exclusion behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/test/java/community/solace/spring/cloud/requestreply/service/RequestReplyExcludeAutoConfigurationTests.java | Adds a full-context test verifying exclusion via spring.autoconfigure.exclude prevents request/reply beans from being contributed. |
| src/test/java/community/solace/spring/cloud/requestreply/service/RequestReplyAutoConfigurationExclusionTests.java | Adds a slice-test regression for issue #8 ensuring @JsonTest starts cleanly without reply-consumer registration. |
| src/main/resources/META-INF/spring.factories | Removes the auto-config-as-initializer registration so it no longer applies to every context. |
| src/main/java/community/solace/spring/cloud/requestreply/service/RequestReplyFunctionRegistrar.java | Introduces registrar that conditionally registers per-binding FunctionRegistration beans only when the auto-config is active. |
| src/main/java/community/solace/spring/cloud/requestreply/service/RequestReplyAutoConfiguration.java | Stops implementing ApplicationContextInitializer and imports the new registrar. |
| README.md | Documents context propagation across async stages and how to exclude the starter in tests. |
| CHANGELOG.md | Adds Unreleased fix note for #8 and the missing 6.0.2 note for #50. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
GreenRover
approved these changes
Jun 22, 2026
SamuelGasser
approved these changes
Jun 23, 2026
nathanaelweber
approved these changes
Jun 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses both open issues.
#8 —
RequestReplyAutoConfigurationcannot be excluded in tests (fix)Root cause: the per-binding reply-consumer registration lived in an
ApplicationContextInitializerregistered throughMETA-INF/spring.factories. Spring Boot applies such initializers to every application context it creates — including sliced tests such as@JsonTest— and they cannot be turned off with@ImportAutoConfiguration(exclude = RequestReplyAutoConfiguration.class)orspring.autoconfigure.exclude. Because the registered reply consumers depend on theRequestReplyServiceImplbean (absent in a slice), the context failed to start withNo bean named 'requestReplyServiceImpl' available.Fix: the registration is moved into a new
RequestReplyFunctionRegistrar(anImportBeanDefinitionRegistrarthat is@Imported byRequestReplyAutoConfiguration), and theApplicationContextInitializerentry is removed fromspring.factories. The registration now runs only when the auto-configuration itself is active, so a slice — or an explicit exclusion — also disables the reply-consumer registration. It still runs during configuration parsing, i.e. early enough for spring-cloud-function/stream to discover theFunctionRegistrationbeans, and resolves the service bean lazily by type. A guard avoids overriding an application-defined bean that happens to share a binding name.#50 — context propagation across asynchronous stages (documentation)
The actual fix (wrapping the executor instead of individual tasks so the captured context is restored for every
CompletableFuturestage, including stages the application chains onto the returned future) was already merged and released in 6.0.2 — it was simply missing from the docs. This PR adds the missing6.0.2CHANGELOG entry and a README section describing the behaviour. No code change for #50.Tests
Both new tests were verified red before the fix and green after:
RequestReplyAutoConfigurationExclusionTests— the reporter's exact@JsonTestslice scenario.RequestReplyExcludeAutoConfigurationTests— explicitspring.autoconfigure.exclude/@ImportAutoConfiguration(exclude = ...).The existing full-context integration tests (sample
@SpringBootApplications consuming the auto-config,bindingMappingand function definitions) continue to pass, confirming normal usage is unaffected.mvn clean package: 87 tests pass, and the packaged jar was verified to contain the correctedspring.factories, the unchangedAutoConfiguration.imports, and the new registrar.Documentation
CHANGELOG.md:Unreleasedentry for [Bug]: The RequestReplyAutoConfiguration class cannot be excluded for tests that do not need it #8 + the missing6.0.2entry for [Bug]: Context propagation not working with asynchronous request/reply #50.README.md: "Context propagation across asynchronous stages" ([Bug]: Context propagation not working with asynchronous request/reply #50) and "Excluding the starter in tests" ([Bug]: The RequestReplyAutoConfiguration class cannot be excluded for tests that do not need it #8).Closes #8
Closes #50