Open GoogleCodeExporter opened 9 years ago
The attached patch fixes the bug (and adds this test into PreloadingTest). The
premise is that eager-loaders are stored only if an explicit "asEagerSingleton"
request is made on the command. Those kinds of loaders are always run. Then,
if
the stage is production, all bindings are iterated through and if the scope of
the
binding (or in the case of a linked binding with no explicit scope, the scope
of its
target binding) is singleton, the binding is also loaded.
It was a little more complicated than just changing LinkedBindingImpl because
of all
creationListeners had to be run before getScope() could be called, otherwise
the
target binding wouldn't have been created yet, which led into very weird JIT
binding
creations.
Original comment by sberlin
on 15 May 2008 at 2:57
Attachments:
Fixed. I really liked your approach, so I took it one step further.
Please code review rev 498 to see if it does what you want:
http://code.google.com/p/google-guice/source/detail?r=498
Original comment by limpbizkit
on 2 Jun 2008 at 7:03
A consequence of the fix is that Guice now eagerly loads all just-in-time
@Singletons. We probably should have
been doing this before.
Original comment by limpbizkit
on 2 Jun 2008 at 4:45
Original issue reported on code.google.com by
sberlin
on 15 May 2008 at 2:00