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

How is ContainerLifeCycleEventRuntimeInvocationTest.testAfterBeanDiscoveryEventFails supposed to pass? #624

Closed
arjantijms opened this issue Jun 7, 2022 · 3 comments

Comments

@arjantijms
Copy link

The CDI TCK test org.jboss.cdi.tck.tests.extensions.lifecycle.events.ContainerLifeCycleEventRuntimeInvocationTest.testAfterBeanDiscoveryEventFails() uses an extension that stores an AfterBeanDiscovery event:

public class TestExtension implements Extension {

    private AfterBeanDiscovery abd;

    void observesAfterBeanDiscovery(@Observes AfterBeanDiscovery event) {
        this.abd = event;
    }

    public AfterBeanDiscovery getAfterBeanDiscovery() {
        return abd;
    }
}

The test then make a call to this stored event later, which is supposed to throw an IllegalStateException

AfterBeanDiscovery event = extension.getAfterBeanDiscovery();

     new Invocation() {
            void execute() {
                event.addBean();
            }
      }.run();

In Weld this throws a NullPointerException, since a postNotify calls sets a receiver to null:

public abstract class ContainerEvent implements NotificationListener {

    private Extension receiver;

    @Override
    public void preNotify(Extension extension) {
        this.receiver = extension;
    }

    @Override
    public void postNotify(Extension extension) {
        this.receiver = null;
    }

And the addBean() from the test uses this receiver and doesn't assume it's null:

@Override
    public <T> WeldBeanConfigurator<T> addBean() {
        return addBean(getReceiver().getClass());
    }

This all happens internally in Weld, without seemingly any option for an integrator to come between this or to influence this.

What is an integrator supposed to do here?

cc: @starksm64 @manovotn

@starksm64
Copy link
Contributor

This is a bug that crept in recently that @manovotn fixed in this PR:
weld/core#2746

There will have to be a new Weld release for this.

@arjantijms
Copy link
Author

Oh wow, thanks for the reference. Isn't the CDI TCK executed for every Weld release?

@manovotn
Copy link
Contributor

manovotn commented Jun 8, 2022

Oh wow, thanks for the reference. Isn't the CDI TCK executed for every Weld release?

It is in embedded and with WFLY. However, in WFLY I wasn't able to execute several tests (this one included) due to issues with other related EE 10 technologies. And this test isn't triggered in embedded mode so it slipped past.
I am just working towards having full WFLY run for each weld PR again so that this situation won't repeat :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants