Skip to content

@EventListener annotated bean cannot be removed from the ApplicationEventMulticaster #26638

Closed
@birnbuazn

Description

@birnbuazn

Affects: 2.4.3

According to the JavaDoc of the ApplicationEventMulticaster I was expecting to be able to remove and/or add ApplicationListeners at runtime.

This currently does not work for @EventListener annotated methods, which apparently lead to a ApplicationListenerMethodAdapter instance at runtime.

Would be great, if we could remove this listener as well, either by

  1. making the Adapter instance injectable and then remove it with multicaster.removeApplicationListener(), or
  2. giving the Adapter instance a well defined bean name and remove it with multicaster.removeApplicationListenerBean()

I've included a small demo app with a failing test to illustrate what I'm trying to achieve:

event-sample.zip

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions