[cdi-dev] [JBoss JIRA] (CDI-732) Clarify that the Context for RequestScoped must be active during @PreDestroy calls

Mark Struberg (JIRA) issues at jboss.org
Mon Jul 16 03:01:00 EDT 2018


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

Mark Struberg commented on CDI-732:
-----------------------------------

> It seems logical to first destroy the "shorter-lived" scopes

Hmm but Welds destroy order according to CDI-730 is
> At present weld destroys conversation, request, then session context in that order.
conversation is clearly longer than request. Thus this argument makes no sense. 

Another point to think about: in CDI the RequestScoped Context is also used as kind of 'ThreadScoped'. For example it is also active in an Asynchronous EJB method, in JBatch threads, etc. 

So even if the Session gets destroyed outside of a HTTP Request (e.g. via timeout), then we could start a RequestContext, perform the @PreDestroy method and stop if afterwards. 

> Clarify that the Context for RequestScoped must be active during @PreDestroy calls
> ----------------------------------------------------------------------------------
>
>                 Key: CDI-732
>                 URL: https://issues.jboss.org/browse/CDI-732
>             Project: CDI Specification Issues
>          Issue Type: Feature Request
>          Components: Contexts
>    Affects Versions: 2.0 .Final
>            Reporter: Mark Struberg
>
> We have the explicit rule that the Context for @RequestScoped must be active during @PostConstruct of any bean. 
> But it seems we don't force the same for invocations of @PreDestroy methods.
> That's especially weird since a few containers now blow up during a destroyal of a @SessionScopedBean which has a @RequestScoped Principal injected, even if the session destroyal was triggered by an explicit Session#invalidate() call in an open HTTP request.



--
This message was sent by Atlassian JIRA
(v7.5.0#75005)


More information about the cdi-dev mailing list