Skip to content

GH-36738: Document rendering-scope limitation of WebFlux RequestContext.changeLocale()#36894

Open
won-seoop wants to merge 1 commit into
spring-projects:mainfrom
won-seoop:fix/36738-webflux-changelocale-javadoc
Open

GH-36738: Document rendering-scope limitation of WebFlux RequestContext.changeLocale()#36894
won-seoop wants to merge 1 commit into
spring-projects:mainfrom
won-seoop:fix/36738-webflux-changelocale-javadoc

Conversation

@won-seoop

Copy link
Copy Markdown

Summary

Closes #36738.

The Spring MVC RequestContext.changeLocale() delegates through the configured LocaleResolver, persisting the new locale for subsequent requests. The WebFlux equivalent updates only a private field on the current RequestContext instance; the change is silently discarded at the end of the rendering cycle. This asymmetry was undocumented, causing developers to expect the same durable behavior as in MVC.

This PR adds Javadoc to both changeLocale overloads in org.springframework.web.reactive.result.view.RequestContext, clearly documenting:

  • The change affects only the current rendering context (not the underlying request or response).
  • It does not delegate to a LocaleContextResolver.
  • It is not persisted beyond the current rendering cycle.
  • For durable locale changes in WebFlux, developers should configure a LocaleContextResolver and update it from a WebFilter or handler method.

Spring MVC's RequestContext.changeLocale() already has explicit Javadoc (including @see LocaleResolver#setLocale) — this PR closes the MVC/WebFlux documentation parity gap for this method.

Test plan

  • Existing tests continue to pass (no behaviour change — Javadoc only)

🤖 Generated with Claude Code

…ux RequestContext.changeLocale()

The Spring MVC RequestContext.changeLocale() delegates through the
configured LocaleResolver and persists the locale across requests. The
WebFlux equivalent only updates a field on the current RequestContext
instance and the change is discarded at the end of the rendering cycle.

This asymmetry was undocumented, leading developers to expect that
calling changeLocale() in a WebFlux template would produce the same
durable effect as in Spring MVC.

Add Javadoc to both WebFlux overloads explaining that the change
affects only the current rendering context, does not delegate to a
LocaleContextResolver, and pointing developers towards the correct
approach (WebFilter + LocaleContextResolver) for durable locale changes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged or decided on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WebFlux RequestContext.changeLocale() lacks Javadoc for rendering-scope limitation (MVC parity gap)

2 participants