<div dir="ltr">Hi,<div><br></div><div>The produced Foo should have been used before it's destroyed, but I'll double check it's also used right before the destroy method is called in the same thread. I'll try to make a simple reproducer as well if it still doesn't work correctly then.</div><div><br></div><div>Kind regards,</div><div>Arjan Tijms</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 15, 2016 at 8:48 AM, Martin Kouba <span dir="ltr"><<a href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Arjan,<br>
<br>
a simple reproducer would be helpful. There are few edge cases around session context and HTTP session which are problematic (e.g. HttpSession.invalidate()).<br>
<br>
Do you call some method on the produced Foo before you call destroy? Because in Weld, normal scoped instances are created lazily and so does the HTTP session in case of @SessionScoped.<br>
<br>
Thanks,<br>
<br>
Martin<br>
<br>
Dne 14.9.2016 v 19:14 arjan tijms napsal(a):<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
Hi,<br>
<br>
I have a simple producer:<br>
<br>
@Produced<br>
@SessionScoped<br>
public void Foo getFoo() { return new Foo());<br>
<br>
If I subsequently want to destroy the Bean using:<br>
<br>
Set<Bean<?>> beans = beanManager.getBeans(Foo.class<wbr>);<br>
<br>
Bean<?> bean = (Bean<T>) beanManager.resolve(beans);<br>
Context context = beanManager.getContext(<a href="http://bean.ge">bean.ge</a><wbr>tScope());<br>
<br>
((AlterableContext) context).destroy(bean);<br>
<br>
Then in Weld 2.3.2 the destroy method of the super class<br>
of <a href="http://org.jboss.weld.context.http.Ht">org.jboss.weld.context.http.Ht</a><wbr>tpSessionContextImpl is called:<br>
<br>
org.jboss.weld.context.Abstrac<wbr>tContext<br>
<br>
Containing this code:<br>
<br>
@Override<br>
public void destroy(Contextual<?> contextual) {<br>
if (!isActive()) {<br>
throw new ContextNotActiveException();<br>
}<br>
checkContextInitialized();<br>
if (contextual == null) {<br>
throw ContextLogger.LOG.contextualIs<wbr>Null();<br>
}<br>
final BeanStore beanStore = getBeanStore();<br>
if (beanStore == null) {<br>
throw ContextLogger.LOG.noBeanStoreA<wbr>vailable(this);<br>
}<br>
BeanIdentifier id = getId(contextual);<br>
ContextualInstance<?> beanInstance = beanStore.remove(id);<br>
if (beanInstance != null) {<br>
RequestScopedCache.invalidate(<wbr>);<br>
destroyContextualInstance(bean<wbr>Instance);<br>
}<br>
}<br>
<br>
Now the getBeanStore() method<br>
(from org.jboss.weld.context.Abstrac<wbr>tBoundContext) returns an<br>
org.jboss.weld.context.beansto<wbr>re.http.LazySessionBeanStore and this bean<br>
store does *not* contain the Foo bean (no key for its BeanIdentifier).<br>
There are other session scoped beans there that have been instantiated<br>
for the test, but Foo is missing.<br>
<br>
If subsequently the session is destroyed, the same destroy method is<br>
called on the<br>
<a href="http://org.jboss.weld.context.http.Ht">org.jboss.weld.context.http.Ht</a><wbr>tpSessionContextImpl eventually, but now<br>
the getBeanStore() method returns<br>
an org.jboss.weld.context.beansto<wbr>re.http.EagerSessionBeanStore, and this<br>
one *does* contain the Foo bean.<br>
<br>
The other beans that the EagerSessionBeanStore contain are equal to the<br>
ones in the LazySessionBeanStore, the only difference is the Foo bean.<br>
<br>
Is this a bug in Weld or am I doing something wrong?<br>
<br>
Kind regards,<br>
Arjan Tijms<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br></div></div>
______________________________<wbr>_________________<br>
weld-dev mailing list<br>
<a href="mailto:weld-dev@lists.jboss.org" target="_blank">weld-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/weld-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailma<wbr>n/listinfo/weld-dev</a><br>
<br>
</blockquote>
</blockquote></div><br></div>