Repository navigation
Preserve advisors on early async bean references - #37656
Open
mdnayanmia31 wants to merge 1 commit into
Open
mdnayanmia31 wants to merge 1 commit into
mdnayanmia31 wants to merge 1 commit into
Conversation
An early self-reference can carry caching advice while the final bean is wrapped in a separate async proxy, so direct calls bypass the cache. Expose advisors during early bean resolution and recognize the same singleton target after initialization to reuse the early proxy. Closes spring-projectsgh-20469 Signed-off-by: Md Nayan Mia <mdnayanmia31@gmail.com>
This branch has not been deployed
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.
Closes gh-20469
Overview
When an async bean obtains a self-reference during initialization, caching
advice is attached to its early proxy, but the final bean is wrapped in a
separate async proxy that bypasses that advice. Expose the advisor during
early bean resolution and recognize the underlying singleton target after
initialization so the bean factory reuses the early proxy, including when
another post-processor has already wrapped it.
Tests
Added
cacheEvictionWithEarlySelfReference()toAsyncAnnotationBeanPostProcessorTests. It verifies asynchronous execution,cache eviction through both the self-reference and the final bean, and that
both references expose the same proxy. The direct eviction assertion failed
before the fix; the complete focused test class passes afterward.
Validated with JDK 25:
AsyncAnnotationBeanPostProcessorTests,AopProxyUtilsTests,AutoProxyCreatorTests, andDefaultAdvisorAutoProxyCreatorTests.checkstyleMainandcheckstyleTestinspring-aopandspring-context.:spring-aop:check :spring-context:check, with unit tests filtered to theclasses above, including the module runtime-hints checks.