Skip to content

EventListenerMethodProcessor unconditionally instantiates certain beans, leading to BeanCreationException during deployment [SPR-13526] #18103

Closed
@spring-projects-issues

Description

@spring-projects-issues

Piotr Findeisen opened SPR-13526 and commented

steps to reproduce
  1. Use <context:annotation-config />
    • this loads EventListenerMethodProcessor
  2. have a prototype bean "A" which uses @Transactional and expects constructor arguments to be provided using org.springframework.beans.factory.BeanFactory.getBean(String, Object...)
    • the bean doesn't need to use @EventListener
  3. start the context
expected
  • context starts
  • if "A" is the only bean (or if nothing uses "A"), the bean is not instantiated at all
observed
  1. EventListenerMethodProcessor wants to know whether "A" is annotated with @EventListener
    1. it calls applicationContext.getType("A")
      1. applicationContext (or rather InfrastructureAdvisorAutoProxyCreator) sees @Transactional ...
      2. ... so sth like A$$EnhancerBySpringCGLIB$$8e7e447 is returned
    2. EventListenerMethodProcessor.getTargetClass sees the bean class is kind of SpringProxy, so...
    3. it instantiates the bean, but obviously not providing required arguments to constructor

Affects: 4.2.1

Issue Links:

Referenced from: commits dbec212

1 votes, 5 watchers

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions