[jbossseam-issues] [JBoss JIRA] Commented: (JBSEAM-3983) @Observer methods may be called multiple times

Norman Richards (JIRA) jira-events at lists.jboss.org
Mon Mar 2 17:57:22 EST 2009

    [ https://jira.jboss.org/jira/browse/JBSEAM-3983?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12455057#action_12455057 ] 

Norman Richards commented on JBSEAM-3983:

So, you have a named component with an @Observer method and a subclass that is also a named component?  Of course, the observer method will be called twice - once for each component.  

As to why your second method isn't being called, I'm guessing that one of your observers is throwing an error of some sort, which would short-circuit any remaining observers from being called.  (I'm not sure if that is "correct", but that's the behavior of Seam now)

I've created a test case that is similar to what you describe, and everything works as expected.   You'll need to attach a broken project or a patch to an existing Seam example that demonstrates the problem.

> @Observer methods may be called multiple times
> ----------------------------------------------
>                 Key: JBSEAM-3983
>                 URL: https://jira.jboss.org/jira/browse/JBSEAM-3983
>             Project: Seam
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.1.1.GA
>            Reporter: Vanessa Williams
>            Assignee: Norman Richards
> Some @Observer methods may be called multiple times, while others may not be called at all. This bug is reproducible; occurs in both 2.1.0 and 2.1.1 and requires specific circumstances (described below.)
> I do not have the time (unfortunately) to create a sample project to demonstrate the problem, but it is easy enough to describe.
> Create an EntityHome<E> subclass, let's call it FooHome.java. Override the persist() method and at the end of it, raise an event, say "fooSaved". Now, in the same class create a method postFooSaved() and annotate it with @Observer("fooSaved"). In any other component you like, create another @Observer method, with a different name, say watchFoo(), observing the same event. In this case, everything works as expected. After FooHome.persist() is called, postFooSaved() and watchFoo() will each be executed once.
> Now to replicate the bug: create a subclass of FooHome.java, say BarHome.java. It doesn't matter what it contains. Now postFooSaved() will be executed twice and watchFoo() will not be executed at all.
> As an extended demonstration, create an action component called FooAction.java and move the original postFooSaved() @Observer to that class. Again, all will work as expected, with postFooSaved() and watchFoo() each executing once. Now create a subclass of FooAction: BarAction.java. The bug will re-appear, with postFooSaved() executing twice and watchFoo() not executing at all.
> Hope that helps.

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the seam-issues mailing list