<div dir="ltr">Hi,<div><br></div><div>I have a simple producer:</div><div><br></div><div>@Produced</div><div>@SessionScoped</div><div>public void Foo getFoo() { return new Foo());</div><div><br></div><div>If I subsequently want to destroy the Bean using:</div><div><br></div><div>Set&lt;Bean&lt;?&gt;&gt; beans = beanManager.getBeans(Foo.class);<br></div><div><br></div><div>Bean&lt;?&gt; bean = (Bean&lt;T&gt;) beanManager.resolve(beans);</div><div>Context context = beanManager.getContext(bean.getScope());<br></div><div><br></div><div>((AlterableContext) context).destroy(bean);<br></div><div><br></div><div>Then in Weld 2.3.2 the destroy method of the super class of org.jboss.weld.context.http.HttpSessionContextImpl is called:</div><div><br></div><div>org.jboss.weld.context.AbstractContext<br></div><div><br></div><div>Containing this code:</div><div><br></div><div><div>    @Override</div><div>    public void destroy(Contextual&lt;?&gt; contextual) {</div><div>        if (!isActive()) {</div><div>            throw new ContextNotActiveException();</div><div>        }</div><div>        checkContextInitialized();</div><div>        if (contextual == null) {</div><div>            throw ContextLogger.LOG.contextualIsNull();</div><div>        }</div><div>        final BeanStore beanStore = getBeanStore();</div><div>        if (beanStore == null) {</div><div>            throw ContextLogger.LOG.noBeanStoreAvailable(this);</div><div>        }</div><div>        BeanIdentifier id = getId(contextual);</div><div>        ContextualInstance&lt;?&gt; beanInstance = beanStore.remove(id);</div><div>        if (beanInstance != null) {</div><div>            RequestScopedCache.invalidate();</div><div>            destroyContextualInstance(beanInstance);</div><div>        }</div><div>    }</div></div><div><br></div><div>Now the getBeanStore() method (from org.jboss.weld.context.AbstractBoundContext) returns an org.jboss.weld.context.beanstore.http.LazySessionBeanStore and this bean store does *not* contain the Foo bean (no key for its BeanIdentifier). There are other session scoped beans there that have been instantiated for the test, but Foo is missing.</div><div><br></div><div>If subsequently the session is destroyed, the same destroy method is called on the org.jboss.weld.context.http.HttpSessionContextImpl eventually, but now the getBeanStore() method returns an org.jboss.weld.context.beanstore.http.EagerSessionBeanStore, and this one *does* contain the Foo bean.</div><div><br></div><div>The other beans that the EagerSessionBeanStore contain are equal to the ones in the LazySessionBeanStore, the only difference is the Foo bean.</div><div><br></div><div>Is this a bug in Weld or am I doing something wrong?</div><div><br></div><div>Kind regards,</div><div>Arjan Tijms</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div>