I agree that this seems wrong with AssistedInject, but I'm not clear on
what you'd otherwise expect. If it didn't cache, then you'd fail with a
StackOverflowException (since you'd recurse forever).

sam
On Mar 6, 2013 9:45 PM, <[email protected]> wrote:

> First, here's a unit test for the issue 
> :https://gist.github.com/electrotype/5105100
>
> I'm trying to use a listener to call an "init()" method on my classes when
> they are constructed. I also use AssistedInject factories.
>
> I think the problem is that in *
> com.google.inject.internal.ConstructorInjector#construct(...)* , this
> code is supposed to prevent infinite loops :
>
>
>     T t = constructionContext.getCurrentReference();
>>     if (t != null) {
>>       return t;
>>     }
>>
>
> To remove the "current reference", *removeCurrentReference()* is called
> in the *finally* clause :
>
>
>     } finally {
>>       constructionContext.removeCurrentReference();
>>     }
>>
>
> The problem is that before this removal method is called, *the listeners
> are called* :
>
>       membersInjector.notifyListeners(t, errors);
>>
>
>
> It seems that this is the root of my issue, because the reference still
> exists when my "init()" methods are called (via the listeners), so when
> they try to create an instance using the factories, they get the cached
> instance instead of a new one!
>
> Does this mean I can't use a listener to call my init() methods? Are there
> some workarounds?
>
> Thanks in advance!
>
>
>
>
>
>
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/google-guice?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to