[weld-issues] [JBoss JIRA] (WELD-892) Calling session-scoped components from session initialized observer goes into infinite loop

Ales Justin (Updated) (JIRA) jira-events at lists.jboss.org
Wed Nov 16 10:24:41 EST 2011


     [ https://issues.jboss.org/browse/WELD-892?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ales Justin updated WELD-892:
-----------------------------

                  Assignee: Ales Justin  (was: Marko Strukelj)
    Workaround Description:   (was: Use a flag and a request-scoped observer class

{code}

@RequestScoped
public class Observer
{
	@Inject
	Pinger pinger;

	private boolean handling;

	public void newSession(@Observes @Initialized HttpSession s)
	{
		if (!handling)
		{
			handling = true;
			pinger.ping();
		}
	}
}
{code})

    
> Calling session-scoped components from session initialized observer goes into infinite loop
> -------------------------------------------------------------------------------------------
>
>                 Key: WELD-892
>                 URL: https://issues.jboss.org/browse/WELD-892
>             Project: Weld
>          Issue Type: Bug
>          Components: Scopes & Contexts
>    Affects Versions: 1.1.1.Final
>            Reporter: Nicklas Karlsson
>            Assignee: Ales Justin
>
> Given a session scoped component
> {code}
> @SessionScoped
> public class Pinger implements Serializable
> {
> 	public void ping()
> 	{
> 	};
> }
> {code}
> and a session initialized observer calling it
> {code}
> public class Observer
> {
> 	@Inject
> 	Pinger pinger;
> 	public void newSession(@Observes @Initialized HttpSession s)
> 	{
> 		pinger.ping();
> 	}
> }
> {code}
> We go off into an infinite loop. Since Pinger doesn't exist, it is created and placed in the session scoped beanstore, which creates a session and fires off the observer. I'm not sure why the session isn't considered created at this point. This is bordering on feature since I think the result would be the same if servlet listeners would be used. Perhaps this could be worked around int the event bridge somehow so that the firing would be prevented if we're already handling the session created event...

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the weld-issues mailing list