Skip to content

Preserve DefaultMessageListenerContainer startup behaviour - #1119

Open
Kyran121 wants to merge 2 commits into
openrewrite:mainfrom
Kyran121:preserve-mongo-listener-container-startup
Open

Preserve DefaultMessageListenerContainer startup behaviour#1119
Kyran121 wants to merge 2 commits into
openrewrite:mainfrom
Kyran121:preserve-mongo-listener-container-startup

Conversation

@Kyran121

@Kyran121 Kyran121 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

What changed

  • Add org.openrewrite.java.spring.data.PreserveMongoListenerContainerAutoStartup.
  • Compose the recipe into UpgradeSpringDataMongoDb_5_0.
  • Evaluate each DefaultMessageListenerContainer return path independently.
  • Preserve manual startup for locally-verifiable paths: direct construction, locally-declared containers, same-block field assignment, and simple one-hop helper methods in the same class.
  • Keep explicit setAutoStartup(...) configuration unchanged.
  • Track variables by JavaType.Variable identity so same-named variables in separate scopes are handled independently.
  • For a supported same-class helper, configure the bean's returned helper result rather than modifying the helper itself, avoiding behavior changes for other callers.
  • Add a targeted diagnostic comment to return paths whose provenance cannot be verified safely, including deeper helper chains, cross-class calls, and fields without a locally-visible assignment.
  • Leave non-Spring-managed instances unchanged.
  • Avoid synthesized variable-name collisions.

Detection boundaries

The recipe deliberately stops short of general interprocedural analysis. A same-class helper is followed one hop only when its returned container is directly constructed or held in a directly-constructed local variable. Explicit startup configuration in that helper is respected. Anything beyond that boundary is left unchanged and marked for manual review.

Tests

Coverage includes:

  • direct constructor returns;
  • locally-declared containers;
  • multiple direct return paths;
  • same-named variables in separate scopes;
  • explicit startup configuration;
  • fields assigned directly before return;
  • fields with unknown provenance;
  • one-hop same-class helpers returning a direct construction;
  • one-hop same-class helpers returning a local variable;
  • helpers with explicit startup configuration;
  • two bean methods sharing the same helper, with both bean return sites configured;
  • a bean and non-bean method sharing the same helper, with only the bean return site configured;
  • deeper helper chains;
  • cross-class helper calls;
  • mixed supported and unsupported return paths in the same bean;
  • non-bean usage;
  • idempotency.

Validation

The focused recipe test suite has been expanded around the per-return provenance model. The PR remains draft while CI validates the updated implementation.

@Kyran121

Kyran121 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

@timtebeek - ready to review

@Kyran121
Kyran121 marked this pull request as draft August 8, 2026 11:00
@Kyran121
Kyran121 force-pushed the preserve-mongo-listener-container-startup branch 6 times, most recently from e63de48 to ef6240a Compare August 8, 2026 13:07
@Kyran121
Kyran121 marked this pull request as ready for review August 11, 2026 15:59
@Kyran121
Kyran121 force-pushed the preserve-mongo-listener-container-startup branch from 5fa7316 to d843089 Compare August 12, 2026 18:14
@Kyran121 Kyran121 closed this Aug 17, 2026
@Kyran121 Kyran121 reopened this Aug 17, 2026
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Aug 17, 2026
@github-project-automation github-project-automation Bot moved this from Done to In Progress in OpenRewrite Aug 17, 2026
Kyran121 and others added 2 commits August 17, 2026 22:09
…Data MongoDB 5.0

Spring Data MongoDB 5 flips DefaultMessageListenerContainer's autoStartup
default from false to true. Add a recipe that finds Spring-managed @bean
methods returning the container without explicit startup configuration
and inserts setAutoStartup(false) to preserve the previous behaviour,
handling multiple return paths, locally-declared and directly-returned
containers, and same-class helper methods, while leaving already-
configured or non-Spring-managed containers untouched and flagging
cases too indirect to update with confidence. Wire it into the
UpgradeSpringDataMongoDb_5_0 composite recipe.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@Kyran121
Kyran121 force-pushed the preserve-mongo-listener-container-startup branch 3 times, most recently from aced5da to 63d8c90 Compare August 19, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

[Spring Data MongoDB 5.0] Preserve DefaultMessageListenerContainer startup behaviour

1 participant