You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openwebbeans.apache.org by "Joe Bergmark (JIRA)" <ji...@apache.org> on 2011/03/08 19:25:59 UTC
[jira] Assigned: (OWB-542) Disposer is called twice on Dependent
beans when injected into a managed object that is called from a JSP
[ https://issues.apache.org/jira/browse/OWB-542?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Joe Bergmark reassigned OWB-542:
--------------------------------
Assignee: Joe Bergmark (was: Gurkan Erdogdu)
> Disposer is called twice on Dependent beans when injected into a managed object that is called from a JSP
> ---------------------------------------------------------------------------------------------------------
>
> Key: OWB-542
> URL: https://issues.apache.org/jira/browse/OWB-542
> Project: OpenWebBeans
> Issue Type: Bug
> Components: Lifecycle
> Affects Versions: 1.0.0
> Environment: standalone Windows environment.
> Reporter: Bill Wigger
> Assignee: Joe Bergmark
> Fix For: 1.1.0
>
> Attachments: patchOWB542.txt
>
> Original Estimate: 2h
> Remaining Estimate: 2h
>
> The Disposer for the "DepDate" dependent bean below will be called twice, when it should only be called once.
> Using a simple JSP with the following EL expression:
> <c:out value="${dateFromProducer.date}"/>
> where dateFromProducer.date resolves to this method in the DateFromProducer class:
> @Named
> public class DateFromProducer {
> @Inject @Named("DepDate") String currentDate;
> public String getDate() { return currentDate; }
> ...
>
> And the Dependent bean is this:
> public class TimeDependentProducer {
> @Produces @Dependent @Named("DepDate") String returnDate() {
> System.out.println("DepDate Producer called");
> GregorianCalendar c = new GregorianCalendar();
> return c.getTime().toString();
> }
>
> void disposeReturnDate(@Disposes @Named("DepDate") String s) {
> System.out.println("DepDate Dipsoser called");
> }
> Fix is to remove the following code from the method "inject(InjectionPoint injectionPoint)"
> in org.apache.webbeans.inject.AbstractInjectable
> // add this dependent into bean dependent list
> if (!WebBeansUtil.isStaticInjection(injectionPoint) && WebBeansUtil.isDependent(injectedBean))
> {
> if(instanceUnderInjection.get() != null)
> {
> ((CreationalContextImpl<?>)this.injectionOwnerCreationalContext).addDependent(instanceUnderInjection.get(),injectedBean, injected);
> }
> }
> that code creates a second entry in the list. The first entry is created because the code right above it:
> //Gets injectable reference for injected bean
> injected = injectionOwnerBean.getWebBeansContext().getBeanManagerImpl().getInjectableReference(injectionPoint, this.injectionOwnerCreationalContext);
> will call "addDependent(....); also.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira