Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BeanPostProcessor won't ever get proxied bean in case of circular references in the bean [SPR-13163] #17754

spring-issuemaster opened this issue Jun 25, 2015 · 1 comment


Copy link

@spring-issuemaster spring-issuemaster commented Jun 25, 2015

Jan Novotný opened SPR-13163 and commented

BeanPostProcessors will obtain reference to unwrapped bean instead of proxy class that handles (for example) transaction attributes of the bean. This happens only for beans that have circular bean references in them.

Steps to reproduce:

  1. load application context with proxy-exporting-example.xml file (correct packages in it)
  2. add PublicInterfacePostProcessor in it
  3. watch it crash :)

One of the beans will come as proxy to the post processor, the other one in unwrapped shape. This happens despite of BeanFactory has both beans in singletons repository proxied.

Workaround for this bug is to pass BeanFactory to the BeanPostProcessor class and do this:

public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
if(bean instanceof PublicInterface) {
Advised proxy = beanFactory.getBean(beanName, Advised.class);
return bean;

Affects: 4.1.6


Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jan 12, 2019

Bulk closing outdated, unresolved issues. Please, reopen if still relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.