Repository navigation
Keep Hooks.enableAutomaticContextPropagation() when the module has no application configuration file - #1306
Open
slayyyyer wants to merge 4 commits into
Open
Keep Hooks.enableAutomaticContextPropagation() when the module has no application configuration file#1306slayyyyer wants to merge 4 commits into
Hooks.enableAutomaticContextPropagation() when the module has no application configuration file#1306slayyyyer wants to merge 4 commits into
Conversation
…on configuration The call was removed from every file in a module that used it, but `AddSpringProperty` only edits application configuration files that already exist, so in a module without one the behaviour disappeared silently. Record the modules that have a main source set application configuration file during the scan, and only replace the call with `spring.reactor.context-propagation=auto` there. A configuration file in a test source set does not count, since the running application would not read it.
The description now states that the call is only replaced in a module that has an application configuration file to add the property to, and that a module without one keeps the call. `recipes.csv` regenerated for the changed description.
`application.yml` in the main source set now asserts that the call is replaced and the property added as nested YAML, so the YAML branch of the configuration check is exercised, not only `application.properties`.
…wn statement `RemoveMethodInvocationsVisitor` also removed the call around a lambda whose body became empty, so a registration or `forEach(..)` lost its invocation. Removing only the statement leaves that call in place. Only the `main` source set, or a file without a source set marker, now counts as the application's configuration.
44 of 84 tasks
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.
Part of #1201 — item B8.
MigrateHooksToReactorContextPropertyremovedHooks.enableAutomaticContextPropagation()from a module and then addedspring.reactor.context-propagation=autoto whateverapplication.properties/application.ymlexisted in the project. A module with no application configuration file of its own, or with one only undersrc/test/resourcesor another source set, lost the call while gaining nothing: automatic context propagation was silently turned off. That is item B8 in #1201.What this changes
JavaProject, that the module has an application configuration file in its main source set (SourceSetmarker plusSpringExecutionContextView's default application configuration paths). The call is replaced only in projects that have both the hook and such a file.RemoveMethodInvocationsVisitorwent with the enclosing call when the invocation was the only statement in a lambda body. The removal is now a block-statement removal, sostream.forEach(arg -> { Hooks.enableAutomaticContextPropagation(); })keeps itsforEachand ends up asstream.forEach(arg -> { });.recipes.csvregenerated; only this recipe's row changed.Is this the right change?
spring-boot-32.yml; this PR only narrows when it acts. No other recipe in the repo or the catalog has the same intent.mainnext toSpringApplication.run— is what the recipe documents, and a module without anapplication.*of its own (a library module, or a multi-module build where configuration lives elsewhere) is ordinary. Those modules are the ones losing behaviour today.Change*recipes cannot express. The property addition itself staysAddSpringProperty.spring.reactor.context-propagationis a Spring Boot 3.2 property (ReactorPropertiesis@since 3.2.0), documented in Observability — Context Propagation and listed under Properties in the Spring Boot 3.2 release notes. The recipe sits in the 3.2 composite.AddSpringProperty, and the lambda case no longer deletes surrounding code.Tests
MigrateHooksToReactorContextPropertyTest, 9 tests, all passing:replaceMethodCallWithProperty,replaceMethodCallWithPropertyInYaml— the documented shape, forapplication.propertiesandapplication.yml.replacesHookOnlyWhereAnApplicationConfigurationFileExists— two modules, only the configured one changes.keepsHookWhenThereIsNoApplicationConfigurationFile(B8),keepsHookWhenConfigurationIsOnlyInTestSources,keepsHookWhenConfigurationIsInAnotherSourceSet— no change.replaceMethodCallThatIsTheOnlyStatementInALambdaBody,keepsTheEnclosingCallWhenTheLambdaBodyBecomesEmpty— the visitor bug.shouldNotAddPropertyWhenNoHooksPresent— no change.The YAML, lambda and custom-source-set tests were each checked to fail with the corresponding part of the fix reverted.
Note on the local run
The declared build plugin (
org.openrewrite.build2.27.4, fromartifacts.codegenomeproject.org) answers 401 anonymously from this machine, so the run used plugin 2.20.0 (rewrite 8.90.x) with the three test sources that need a newer rewrite excluded. On that setup the full suite matchesmain: 64 failures, identical per class, all failing the same way on unmodifiedmain. CI will run the declared versions.