[jbossseam-issues] [JBoss JIRA] Commented: (JBSEAM-3362) Detect cyclic dependencies and throw exception

Matt Drees (JIRA) jira-events at lists.jboss.org
Mon Sep 1 12:36:09 EDT 2008


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

Matt Drees commented on JBSEAM-3362:
------------------------------------

1) I'll take a look
2) Correct me if I'm wrong here.  My understanding of what you'd like is this:
Say Foo has an @In(required=false) attribute called somethingProvidedByBar.  When someMethod() is invoked on Foo, and trying to satisfy the injection of bar results in Bar calling Foo.someOtherMethod(), then we should bail on this injection attempt, and let somethingProvidedByBar be null for the invocation of someMethod().

I see the desirability of this, but I don't know how to do the "bail" part.  A cycle is only detected when someOtherMethod() is called, and so trying to bail would probably require throwing a special exception to propagate back down to the initial injecting of Foo, where we'd catch it and go on to the next attribute to inject.  But throwing exceptions seems like a bad idea, especially when they might inadvertently cause a transaction rollback.

Let me know what you think.



> Detect cyclic dependencies and throw exception
> ----------------------------------------------
>
>                 Key: JBSEAM-3362
>                 URL: https://jira.jboss.org/jira/browse/JBSEAM-3362
>             Project: Seam
>          Issue Type: Feature Request
>          Components: Core
>    Affects Versions: 2.0.3.CR1, 2.1.0.BETA1
>            Reporter: Matt Drees
>            Assignee: Matt Drees
>            Priority: Minor
>             Fix For: 2.0.3.CR2, 2.1.0.CR1
>
>
> Imagine a scenario like this.  Some client calls someMethod() on a component called Foo.  BijectionInterceptor tries to inject Foo's @in attributes, one of which requires calling a factory method on Bar.  Bar's factory method in turn calls Foo.someOtherMethod().  Foo is not in a state where it can support method calls, because it is in the process of injecting dependencies, so this sort of cyclic dependency should not be allowed.  Seam should throw an exception in this case.
> BijectionInterceptor used to be coded such that someOtherMethod() would run without any complaints, and any @In attributes may or may not be null, depending on which fields were injected first.  Recent changes to BijectionInterceptor (for JBSEAM-3295) have changed this behavior, and now an finite loop results.  Neither of these behaviors is desirable.

-- 
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