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

Closed
spring-projects-issues opened this issue Jun 25, 2015 · 1 comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: bulk-closed An outdated, unresolved issue that's closed in bulk as part of a cleaning process

Comments

@spring-projects-issues
Copy link
Collaborator

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:

{{@Override
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

Attachments:

@spring-projects-issues spring-projects-issues added type: bug A general bug status: waiting-for-triage An issue we've not yet triaged or decided on in: core Issues in core modules (aop, beans, core, context, expression) and removed type: bug A general bug labels Jan 11, 2019
@rstoyanchev rstoyanchev added status: bulk-closed An outdated, unresolved issue that's closed in bulk as part of a cleaning process and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jan 11, 2019
@spring-projects-issues
Copy link
Collaborator Author

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
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: bulk-closed An outdated, unresolved issue that's closed in bulk as part of a cleaning process
Projects
None yet
Development

No branches or pull requests

2 participants