Skip to content

ApplicationListener no longer invoked for generic ApplicationEvent with 6.2.0 #33982

Closed
@denAbramoff

Description

@denAbramoff

Hello!

I have simple interface like this:

public interface ITest
{
}

and the simple event:

public class TestEvent<T extends ITest> extends ApplicationEvent
{
    public TestEvent(Object source)
    {
        super(source);
    }
}

and two listeners:

@Component
public class MethodListener
{
    @EventListener
    public void handleTestEvent(TestEvent<ITest> iTest)
    {
        System.out.println(this.getClass() + " DONE!");
    }
}
@Component
public class SimpleTestListener implements ApplicationListener<TestEvent<ITest>>
{
    @Override
    public void onApplicationEvent(TestEvent<ITest> event)
    {
        System.out.println(this.getClass() + " DONE!");
    }
}

and when i trying to send an event via the spring context like this:

public class MySpringApplication
{
    public static void main(String[] args)
    {
        ApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
        context.publishEvent(new TestEvent<>(""));
    }
}

i have different result in depends on the version Spring. When i use Spring 6.2 i can see in the log this:

class ... MethodListener DONE!

when i use Spring 6.1.15 i see both results:

class ...SimpleTestListener DONE!
class ...MethodListener DONE!

I guess it's a bug.

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: regressionA bug that is also a regression

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions