Skip to content

Document @RefreshScope + @ControllerAdvice double-invocation issue (GH-1452)#3248

Open
won-seoop wants to merge 1 commit into
spring-cloud:mainfrom
won-seoop:doc-refreshscope-controlleradvice
Open

Document @RefreshScope + @ControllerAdvice double-invocation issue (GH-1452)#3248
won-seoop wants to merge 1 commit into
spring-cloud:mainfrom
won-seoop:doc-refreshscope-controlleradvice

Conversation

@won-seoop

Copy link
Copy Markdown

Summary

Closes GH-1452

Applying @RefreshScope directly to a @ControllerAdvice bean causes Spring MVC to discover both the CGLIB proxy (from the refresh scope) and the underlying target class. As a result, @ModelAttribute methods are invoked twice per request.

The maintainers already recommended the workaround in the issue thread: extract refreshable values to a separate @ConfigurationProperties bean with @RefreshScope and inject it into the advice. However, this was never documented, leaving users to discover it on their own.

Changes

Added a new [[refresh-scope-known-limitations]] section to client.adoc (placed before the AOT section at the end of the page):

  • Explains the root cause: CGLIB proxy + component-scan double-registration
  • Provides a concrete before/after code example showing the workaround
  • Uses callout annotations to highlight which bean gets @RefreshScope and which doesn't

Test plan

  • Verify AsciiDoc renders correctly
  • Confirm new section appears in the navigation/ToC

🤖 Generated with Claude Code

…pring-cloudGH-1452)

Add a 'Refresh Scope Known Limitations' section to the client docs
documenting that applying @RefreshScope directly to @ControllerAdvice
beans causes @ModelAttribute methods to be invoked twice per request
due to CGLIB proxy double-registration.

Include the recommended workaround: extract the refreshable config into
a separate @ConfigurationProperties/@RefreshScope bean and inject it
into the @ControllerAdvice without @RefreshScope on the advice itself.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@RefreshScope and component-scanned @ControllerAdvice beans.

2 participants