Status: New
Owner: ----
New issue 282 by phopkins: Optional dependencies bound in child injectors
not injected into JIT-bound instances
http://code.google.com/p/google-guice/issues/detail?id=282
I've found a case where optional dependencies (@Inject(optional = true))
may not be satisfied if the class with the dependencies is built with a JIT
binding and there's a parent injector.
What seems to happen is that the just-in-time binding bubbles up to the
parent module, but the class to satisfy the optional dependency is bound in
the child. The parent can't get to the dependency in the child (the
state#isBlacklisted check fails) and an error occurs.
Unfortunately, since the dependency is optional, the error is ignored and
the SingleMethodInjector is then discarded. If the dependency is required,
things succeed (I haven't tracked this further, but it seems it triggers a
retry?).
Attached some simple test cases that show that the problem occurs when
child injectors and optional dependencies come together.
Found in the snapshot20081123 release.
Btw, if you can advise on a strategy for solving this (doing the JIT in the
child? propogating the optional error further rather than ignoring it?) I'd
be happy to take a stab at a patch.
Attachments:
guice-optional-parent.txt 1.2 KB
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"google-guice-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-guice-dev?hl=en
-~----------~----~----~----~------~----~------~--~---