You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openwebbeans.apache.org by "Bill Wigger (JIRA)" <ji...@apache.org> on 2011/03/08 15:56:59 UTC

[jira] Created: (OWB-542) Disposer is called twice on Dependent beans when injected into a managed object that is called from a JSP

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: Gurkan Erdogdu
             Fix For: 1.1.0


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

[jira] Commented: (OWB-542) Disposer is called twice on Dependent beans when injected into a managed object that is called from a JSP

Posted by "Mark Struberg (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OWB-542?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13003986#comment-13003986 ] 

Mark Struberg commented on OWB-542:
-----------------------------------

Bill, did you test this with the latest snapshot (from yesterday)? I've changed quite a lot recently. Can you please retest this with a new build openwebbeans trunk?
txs!

> 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: Gurkan Erdogdu
>             Fix For: 1.1.0
>
>   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

[jira] Commented: (OWB-542) Disposer is called twice on Dependent beans when injected into a managed object that is called from a JSP

Posted by "Mark Struberg (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OWB-542?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13004756#comment-13004756 ] 

Mark Struberg commented on OWB-542:
-----------------------------------

txs Joe! Somehow my svn client didn't show AbstractInjectable as dirty. I've now committed the change.

> 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

[jira] Resolved: (OWB-542) Disposer is called twice on Dependent beans when injected into a managed object that is called from a JSP

Posted by "Mark Struberg (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OWB-542?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mark Struberg resolved OWB-542.
-------------------------------

    Resolution: Fixed

> 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

[jira] Reopened: (OWB-542) Disposer is called twice on Dependent beans when injected into a managed object that is called from a JSP

Posted by "Mark Struberg (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OWB-542?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mark Struberg reopened OWB-542:
-------------------------------


seems this patch broke the TCK

> 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

[jira] Resolved: (OWB-542) Disposer is called twice on Dependent beans when injected into a managed object that is called from a JSP

Posted by "Joe Bergmark (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OWB-542?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Joe Bergmark resolved OWB-542.
------------------------------

    Resolution: Fixed

> 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

[jira] Updated: (OWB-542) Disposer is called twice on Dependent beans when injected into a managed object that is called from a JSP

Posted by "Bill Wigger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OWB-542?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bill Wigger updated OWB-542:
----------------------------

    Attachment: patchOWB542.txt

patch/fix attached.

> 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: Gurkan Erdogdu
>             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

[jira] Commented: (OWB-542) Disposer is called twice on Dependent beans when injected into a managed object that is called from a JSP

Posted by "Joe Bergmark (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OWB-542?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13004012#comment-13004012 ] 

Joe Bergmark commented on OWB-542:
----------------------------------

I'm working on a unit test for this, but I believe it is still occurring.

The problem only appears to occur when a dependent scoped bean from a producer is injected into another dependent scoped bean.  In that case it gets added twice as Bill pointed out.  Once while processing getInjectableReference, and then again in that special code block check for WebBeansUnit.isDependentent(injectedBean) in AbstractInjectable.  That second check appears redundant.

> 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: Gurkan Erdogdu
>             Fix For: 1.1.0
>
>   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

[jira] Commented: (OWB-542) Disposer is called twice on Dependent beans when injected into a managed object that is called from a JSP

Posted by "Joe Bergmark (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OWB-542?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13004601#comment-13004601 ] 

Joe Bergmark commented on OWB-542:
----------------------------------

I'm seeing the unit test I added fail, but apparently it is now failing because the disposer is not called at all, rather than before where it failed because it was being called twice.

Failed tests: 
  testDisposerMethodWithIntermediateDependent(org.apache.webbeans.newtests.disposes.DependentMethodBeanTest)



> 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

[jira] Assigned: (OWB-542) Disposer is called twice on Dependent beans when injected into a managed object that is called from a JSP

Posted by "Joe Bergmark (JIRA)" <ji...@apache.org>.
     [ 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

[jira] Commented: (OWB-542) Disposer is called twice on Dependent beans when injected into a managed object that is called from a JSP

Posted by "Mark Struberg (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OWB-542?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13004022#comment-13004022 ] 

Mark Struberg commented on OWB-542:
-----------------------------------

yes, there is a good chance that we will get rid of this and other similar problems if we review our use of 'parent CreationalContexts'. 

Let me explain a bit:
Currently our CreationalContextImpl contains a List of <DependentCreationalContext>s which basically is just a parentObject, injectedObject holder.

So basically CreationalContextImpl#dependentObjects contains a flattened out TREE of all dependent objects!

Thats good so far, but we currenly create new CreationalContexts way too often instead of handing over just the one which got used to create the 'root' node of all those dependent instances.

> 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: Gurkan Erdogdu
>             Fix For: 1.1.0
>
>   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

[jira] Updated: (OWB-542) Disposer is called twice on Dependent beans when injected into a managed object that is called from a JSP

Posted by "Bill Wigger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OWB-542?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bill Wigger updated OWB-542:
----------------------------


Same problem with newly downloaded code.

> 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: Gurkan Erdogdu
>             Fix For: 1.1.0
>
>   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

[jira] Commented: (OWB-542) Disposer is called twice on Dependent beans when injected into a managed object that is called from a JSP

Posted by "Mark Struberg (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OWB-542?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13004495#comment-13004495 ] 

Mark Struberg commented on OWB-542:
-----------------------------------

I now committed a new fix. The idea behind all the CreationalContext stuff is that it only contains Dependent objects! So I re-activated the general addDependent for Dependent scoped beans and completely removed the invocation in the ProducerMethodBean.

Not all our internal tests passes as well as the JSR-299 and JSR-330 TCKs.

> 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