Skip to content

ApplicationListener no longer invoked for double generic ApplicationEvent with 6.2.1 #34234

@denAbramoff

Description

@denAbramoff

This issue is next step this issue.

So:

I have simple interface like this:

public interface ITest
{
}

and this:

public interface ITest2
{
}

and the simple event:

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

and listener:

import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

@Component
public class MyListener<T extends ITest & ITest2> implements ApplicationListener<TestEvent<T>>
{
    @Override
    public void onApplicationEvent(TestEvent<T> 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.1 i can't see in the log anything.

when i use Spring 6.1.16 i see this result:

class ...MyListener 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