Open GoogleCodeExporter opened 9 years ago
Update: I've not seen any issues testing this locally, so I might commit this
fix to the sisu-guice branch and let it bake some more.
Original comment by mccu...@gmail.com
on 21 Mar 2013 at 3:51
Thanks, Stuart -- I completely forgot about this, so haven't had a chance to
test it internally. I'll give it a go this weekend & see how things fare.
Original comment by sberlin
on 21 Mar 2013 at 3:55
Is this fix going to be included in the 3.1.0 release? I have to say I begin to
have a lot of lazy init() calls to workaround the issue. Thanks!
Original comment by electrot...@gmail.com
on 30 Mar 2013 at 2:51
FYI, things are looking pretty good, I don't see any breakages from the change
so far, so I'm inclined to commit it. FWIW, I rewrote the test a bit so it
doesn't require assistedinject. See below
--
public void testProvisionIsNotifiedAfterContextsClear() {
Injector injector = Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
bindListener(Matchers.any(), new ProvisionListener() {
@Override
public <T> void onProvision(ProvisionInvocation<T> provision) {
Object provisioned = provision.provision();
if (provisioned instanceof X) {
((X)provisioned).init();
} else if (provisioned instanceof Y) {
X.createY = false;
((Y)provisioned).init();
}
}
});
}
});
X.createY = true;
X x = injector.getInstance(X.class);
assertNotSame(x, x.y.x);
assertFalse("x.ID: " + x.ID + ", x.y.x.iD: " + x.y.x.ID, x.ID == x.y.x.ID);
}
private static class X {
final static Random RND = new Random();
static boolean createY;
final int ID = RND.nextInt();
final Provider<Y> yProvider;
Y y;
@Inject X(Provider<Y> yProvider) {
this.yProvider = yProvider;
}
void init() {
if (createY) {
this.y = yProvider.get();
}
}
}
private static class Y {
final Provider<X> xProvider;
X x;
@Inject Y(Provider<X> xProvider) {
this.xProvider = xProvider;
}
void init() {
this.x = xProvider.get();
}
}
Original comment by sberlin
on 30 Mar 2013 at 6:18
Fixed in:
https://code.google.com/p/google-guice/source/detail?r=2cc8ce904aff3d46a55cb6b88
6e975516a923524
Original comment by cgruber@google.com
on 16 May 2013 at 6:45
Original issue reported on code.google.com by
mccu...@gmail.com
on 7 Mar 2013 at 3:54