[ 
https://issues.apache.org/jira/browse/DELTASPIKE-1198?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16001886#comment-16001886
 ] 

Sean Flanigan edited comment on DELTASPIKE-1198 at 5/9/17 2:42 AM:
-------------------------------------------------------------------

[~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 
https://github.com/apache/deltaspike/compare/master...seanf:DELTASPIKE-1197 
(and [DELTASPIKE-1197 comment 
15431960|https://issues.apache.org/jira/browse/DELTASPIKE-1197?focusedCommentId=15431960&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-15431960])

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?

{code:java}
    public static boolean isActive()
    {
        return bmpSingleton != null && 
bmpSingleton.bmInfos.containsKey(ClassUtils.getClassLoader(null));
    }
{code}


was (Author: sflanigan):
[~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 
https://github.com/apache/deltaspike/compare/master...seanf:DELTASPIKE-1197 ( 
https://issues.apache.org/jira/browse/DELTASPIKE-1197?focusedCommentId=15431960&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-15431960
 )

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?

{code:java}
    public static boolean isActive()
    {
        return bmpSingleton != null && 
bmpSingleton.bmInfos.containsKey(ClassUtils.getClassLoader(null));
    }
{code}

> BeanManagerProvider.isActive() returns true after container shutdown
> --------------------------------------------------------------------
>
>                 Key: DELTASPIKE-1198
>                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-1198
>             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 RegistrySingletonProvider.java.
> 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
(v6.3.15#6346)

Reply via email to