deltaspike-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sean Flanigan (JIRA)" <>
Subject [jira] [Commented] (DELTASPIKE-1198) BeanManagerProvider.isActive() returns true after container shutdown
Date Tue, 09 May 2017 01:13:04 GMT


Sean Flanigan commented on DELTASPIKE-1198:

[~struberg] I'm afraid I'm a bit rusty on this code by now, but in my own project I have a
test suite which uses CDI-Unit (based on Weld SE) along with plain (non-CDI) unit tests, trying
to use CDIAwareConstraintValidatorFactory in both environments, which is why I needed DELTASPIKE-1197.

See my changes in

I think it was accessing the {{BeanManager}} via {{bmpSingleton}} (which is static). As I
said in the description, it would be good to null it out at shutdown, but when I tried that
I found that it broke a number of DeltaSpike's tests. I can't reproduce those test failures
now, but as I said, I'm a bit rusty on this.

Anyway, I suppose the real problem is that {{isActive}} is that it doesn't agree with {{cleanupStoredBeanManagerOnShutdown}},
since the cleanup method just removes things from a map, but {{isActive}} doesn't look inside
that map. 

If for some reason {{bmpSingleton}} can't be set to null, what if {{isActive}} were something
like this?

    public static boolean isActive()
        return bmpSingleton != null && bmpSingleton.bmInfos.containsKey(ClassUtils.getClassLoader(null));

> BeanManagerProvider.isActive() returns true after container shutdown
> --------------------------------------------------------------------
>                 Key: DELTASPIKE-1198
>                 URL:
>             Project: DeltaSpike
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 1.7.0, 1.7.2
>            Reporter: Sean Flanigan
>            Assignee: Mark Struberg
> While trying to implement DELTASPIKE-1197 I found that {{BeanManagerProvider.isActive()}}
returns true after container shutdown.
> The javadocs for {{isActive()}} say "@return true if the BeanManagerProvider is ready
to be used", but when it is in this state, the BeanManagerProvider can't actually be used
because the CDI container is not active. 
> In the case of Weld, when {{BeanProvider.getContextualReference()}} was called I got
errors like "java.lang.IllegalStateException: Singleton not set for STATIC_INSTANCE =>
[]". There was no stack trace, but that message comes from Weld's
> It would seem reasonable to reset bmpSingleton to null during cleanupStoredBeanManagerOnShutdown,
but for some reason this breaks a lot of tests.

This message was sent by Atlassian JIRA

View raw message