Skip to content

chore(deps): Spring Boot 4.2.0, fix EnvironmentPostProcessor registration - #402

Merged
devondragon merged 4 commits into
mainfrom
chore/spring-boot-4.2
Dec 1, 2026
Merged

devondragon merged 4 commits into
mainfrom
chore/spring-boot-4.2

Conversation

@devondragon

Copy link
Copy Markdown
Owner

Supersedes #400 (Dependabot bump from Spring Boot 4.1.2 to 4.2.0), which fails to compile.

Why #400 fails

Spring Boot 4.2 removes the deprecated org.springframework.boot.env.EnvironmentPostProcessor. MessageSourceEnvironmentPostProcessor implemented it, so compileJava fails. It now implements org.springframework.boot.EnvironmentPostProcessor, which has existed since Boot 4.0.

Bug fixed along the way (present since 5.0.0)

The post-processor was registered in META-INF/spring/org.springframework.boot.env.EnvironmentPostProcessor.imports. Spring Boot only discovers environment post-processors through META-INF/spring.factories, so it never ran. Running a real SpringApplication on main (Boot 4.1.2) confirmed that the library bundle was never appended to spring.messages.basename. Java callers hid this with English fallbacks, but templates with no fallback (the passkey-registered email) rendered ??key??.

Changes

  • MessageSourceEnvironmentPostProcessor: switches to the new interface.
  • Registration: moved from the .imports file to META-INF/spring.factories.
  • MessageSourceEnvironmentPostProcessorTest: adds a test that boots a real SpringApplication and checks the merged basename. The existing tests call mergeBasename() directly, so they could not catch a registration Spring Boot never loads.
  • CHANGELOG [Unreleased], MIGRATION.md (compatibility matrix and a note in the 5.0 message bundle section), and the README compatibility text now cover Boot 4.2.

Verification

  • ./gradlew build on Boot 4.2.0: 1,286 tests, 0 failures.
  • Compiling with -Xlint:deprecation: no new deprecation warnings compared with main, apart from the one this change removes.
  • Release integration test (docs/RELEASE-TESTING.md) against 5.4.2-SNAPSHOT:
    • Demo clean test (demo on Boot 4.1.1): 312 tests, 0 failures (182 skipped, same as the 5.4.1 baseline).
    • Playwright chromium: 107 passed, 0 failed.
    • Playwright chromium-mfa: 1 passed, 0 failed.
  • Demo on Boot 4.2.0 with 5.4.2-SNAPSHOT: 312 tests, 0 failures. Demo on Boot 4.2.0 with released 5.4.1: also 0 failures, so consumers can move to Boot 4.2 before upgrading the library.

dependabot Bot and others added 3 commits November 30, 2026 20:47
Bumps [org.springframework.boot](https://github.com/spring-projects/spring-boot) from 4.1.2 to 4.2.0.
- [Release notes](https://github.com/spring-projects/spring-boot/releases)
- [Commits](spring-projects/spring-boot@v4.1.2...v4.2.0)

---
updated-dependencies:
- dependency-name: org.springframework.boot
  dependency-version: 4.2.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
…g Boot 4.2

Spring Boot 4.2 removes the deprecated org.springframework.boot.env.EnvironmentPostProcessor
interface, which broke compilation. Switch MessageSourceEnvironmentPostProcessor to
org.springframework.boot.EnvironmentPostProcessor (available since Boot 4.0).

Also move its registration from META-INF/spring/...EnvironmentPostProcessor.imports to
META-INF/spring.factories. Spring Boot only discovers environment post-processors through
spring.factories, so since 5.0.0 the post-processor never ran and the library message bundle
was not added to spring.messages.basename. Add a test that runs a real SpringApplication to
cover the registration.
@claude

claude Bot commented Dec 1, 2026

Copy link
Copy Markdown

Review

Overall this looks good: a focused fix with good verification.

What I checked

  • Switching to org.springframework.boot.EnvironmentPostProcessor is the right fix for the Boot 4.2 compile failure. The PR notes the interface exists since Boot 4.0, so 4.0 and 4.1 consumers are covered.
  • Moving the registration to META-INF/spring.factories fixes a real bug. Boot only discovers environment post-processors through spring.factories, and the old .imports file was never read.
  • The new SpringApplication-based test covers the registration, which the existing mergeBasename() tests couldn't. It closes the right gap.

Suggestions (non-blocking)

  1. Behaviour change for existing consumers. The post-processor will now run for the first time in 5.0 through 5.4.1 apps. It is additive and de-duplicated, so the risk is low. Apps that rely on MessageSourceAutoConfiguration conditions, such as a custom messageSource bean or spring.messages.basename set to something unexpected, may see different resolution. The CHANGELOG notes this, and I'd keep the "Fixes" wording prominent in the release notes.
  2. Test robustness. The test passes --spring.messages.basename=messages/messages without a matching bundle on the test classpath. That's fine for asserting the property, but it's worth confirming no messages/messages resource is needed. Also consider a case with no consumer basename set, to check the default messages is preserved in the merge.
  3. Test isolation. app.run loads the full classpath auto-configuration, including this library's. If the test environment ever lacks a datasource, the context could fail for unrelated reasons. It passes now, but spring.autoconfigure.exclude or a minimal property set would make it sturdier.
  4. Docs nit. The README quick-start still shows 5.4.1. This is probably intentional until release. The "built and verified against 4.2.x" text is accurate for main.
  5. Consider a one-line comment in spring.factories explaining why it isn't in META-INF/spring/*.imports, so nobody "modernizes" it back.

No security or performance concerns. Approving in spirit; the CI result on Boot 4.2.0 is the main gate.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The changes are limited and focused on Spring Boot 4.2 compatibility and proper EnvironmentPostProcessor discovery, with explicit registration via spring.factories and a SpringApplication-based test plus documentation updates providing supporting evidence and no outstanding issues noted.

No open issues 🎉

What changed in this PR

Updates the project for Spring Boot 4.2.0 compatibility and fixes environment post-processor discovery so the library’s message bundle is appended to spring.messages.basename at runtime.

Changes:

  • Bump the Spring Boot Gradle plugin to 4.2.0 and update MessageSourceEnvironmentPostProcessor to implement org.springframework.boot.EnvironmentPostProcessor.
  • Register the environment post-processor via META-INF/spring.factories so Spring Boot discovers and runs it.
  • Add a SpringApplication-based test to verify real Boot discovery and merged basename behavior, and update README/MIGRATION/CHANGELOG for Boot 4.2 support and the registration fix.
File Description
src/​test/​java/​com/​digitalsanctuary/​spring/​user/​MessageSourceEnvironmentPostProcessorTest.java Adds a SpringApplication-based test to confirm the environment post-processor is discovered via spring.factories and merges spring.messages.basename correctly.
src/​main/​resources/​META-INF/​spring.factories Registers MessageSourceEnvironmentPostProcessor under org.springframework.boot.EnvironmentPostProcessor for Spring Boot runtime discovery.
src/​main/​java/​com/​digitalsanctuary/​spring/​user/​MessageSourceEnvironmentPostProcessor.java Updates the post-processor to use the non-deprecated Boot 4.x EnvironmentPostProcessor interface while preserving basename merge behavior and ordering.
README.md Updates documented compatibility to include Spring Boot 4.2.x and adjusts related wording.
MIGRATION.md Documents the historical environment post-processor registration issue and the fix, and updates the compatibility matrix/details for Boot 4.2.
CHANGELOG.md Notes the Boot 4.2 upgrade and the environment post-processor registration/message bundle fix under Unreleased.
build.gradle Bumps the Spring Boot Gradle plugin version to 4.2.0.

Review effort: Balanced
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.

@devondragon

Copy link
Copy Markdown
Owner Author

Review follow-up in aad10a5:

  • 2: Added a test for the case where no consumer basename is set; it expects messages,messages/dsspringusermessages. Both registration tests now point spring.config.location at an empty location, because the test classpath's application.yml sets spring.messages.basename. The new test caught that.
  • 3: No change. The test boots a plain @Configuration class without @EnableAutoConfiguration, so no auto-configuration (including this library's) loads.
  • 5: Added a comment in spring.factories explaining why the entry must stay there.
  • 1 and 4: The release notes lead with the Fixes entry. The README install snippets get bumped to 5.4.2 after the release, as usual.

@claude

claude Bot commented Dec 1, 2026

Copy link
Copy Markdown

Review

Overall this is a solid, well-scoped PR. The root-cause analysis is convincing: .imports files aren't read for environment post-processors, and the real-SpringApplication test is the right way to guard against that regression.

Good

  • Switching to org.springframework.boot.EnvironmentPostProcessor is the minimal fix for the 4.2 compile break.
  • The spring.factories comment explains why it must not move back to .imports.
  • Two registration tests cover both the consumer-basename and default-basename paths. ISOLATED_CONFIG keeps them independent of the test classpath's application.yml.
  • Changelog, migration and README updates are thorough, including the forwarded-headers upgrade note.

Suggestions / risks

  1. Boot 4.0.x compatibility isn't verified. The docs claim 4.0.x and 4.1.x still work. The PR's verification only covers the demo app on 4.1.1 and 4.2.0, and the library build on 4.2.0. Please confirm that 4.0.x's EnvironmentPostProcessorApplicationListener loads the org.springframework.boot.EnvironmentPostProcessor key from spring.factories. If it only honors the old org.springframework.boot.env.EnvironmentPostProcessor key there, the fix silently won't apply on 4.0. A quick run of the new test, or the demo app, with the Boot version pinned to 4.0.x would settle it.
  2. Behaviour change for existing consumers. The post-processor now actually runs for the first time. This is the intended fix, but consumers with custom spring.messages.basename or message keys that collide with the library's will see changes. The changelog covers this (own keys take precedence), so it's worth a note in the release.
  3. Test hygiene (minor). app.run(...) starts a full context. If a MessageSourceAutoConfiguration or other auto-config on the test classpath is slow or has side effects, consider spring.main.lazy-initialization=true. This is optional.
  4. Docs wording (nit). README says 5.4.x is "built and verified against 4.2.x" while the same sentence says 5.4.0/5.4.1 were built against 4.1.1. It's accurate but slightly confusing. Consider "later 5.4.x releases".

No security or performance concerns. Once the 4.0.x loading question is confirmed, this looks good to merge.

🤖 Generated with Claude Code

@devondragon
devondragon merged commit b4b6088 into main Dec 1, 2026
4 checks passed
@devondragon
devondragon deleted the chore/spring-boot-4.2 branch December 1, 2026 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants