[cdi-dev] [JBoss JIRA] (CDI-743) NPE when trying to get BeanManager after container was closed

Matej Novotny (Jira) issues at jboss.org
Fri Feb 15 09:43:00 EST 2019


    [ https://issues.jboss.org/browse/CDI-743?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13696039#comment-13696039 ] 

Matej Novotny edited comment on CDI-743 at 2/15/19 9:42 AM:
------------------------------------------------------------

Actually, I think that {{getCDIProvider()}} method should probably check upon every access that the chosen provider (even the cached one) still returns non-null value from {{getCDI()}}.

That, or better still, it should catch ISE from the invocation of {{getCDI()}} because currently it doesn't take into consideration that providers would do that despite the fact that {{getCDI()}} contract clearly states ISE as a valid "return" option.

Imagine a situation with multiple CDI providers and you read Weld's one first and since no Weld container runs at the moment, it blows up with ISE. Now what{{CDI}} does is that it stops iterating over all providers and proliferates this exception to you effectively hiding remaining CDI providers that could have worked.


was (Author: manovotn):
Actually, I think that {{getCDIProvider()}} method should probably check upon every access that the chosen provider (even the cached one) still returns non-null value from {{getCDI()}}.

That, or it should catch ISE from the invocation of {{getCDI()}} because currently it doesn't take into consideration that providers would do that.
Imagine a situation with multiple CDI providers and you read Weld's one first and since no Weld container runs at the moment, it blows up with ISE. Now what{{CDI}} does is that it stops iterating over all providers and proliferates this exception to you.

> NPE when trying to get BeanManager after container was closed
> -------------------------------------------------------------
>
>                 Key: CDI-743
>                 URL: https://issues.jboss.org/browse/CDI-743
>             Project: CDI Specification Issues
>          Issue Type: Bug
>    Affects Versions: 2.0 .Final, 2.0.SP1
>         Environment: simple application that uses weld-se-core and cdi api.
>            Reporter: Doychin Bondzhev
>            Priority: Major
>
> CDI.current() should produce IllegalStateException when there is no active container at the moment.
> Instead on the second call in the sample application CDI.current() returns null and that results in NPE. 



--
This message was sent by Atlassian Jira
(v7.12.1#712002)


More information about the cdi-dev mailing list