Status: New
Owner: ----
New issue 742 by [email protected]: AssistedInject inconsistency for
Singleton return types
http://code.google.com/p/google-guice/issues/detail?id=742
FactoryModuleBuilder doesn't respect Singleton annotations of returned
types. I know this is not the intended usage of FactoryModuleBuilder but
due to refactorings we encountered this situtation on site. It could have
failed early instead of creating new types.
Following unit test fails, instead of throwing an exception during injector
creation:
public class FactoryModuleBuilderSingletonTest {
@Singleton
public static class ASingleton {
}
public static interface SingletonsFactory {
ASingleton getSingleton();
}
@Test
public void factoryModuleBuilderShouldRespectSingleton() {
Injector injector = Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
install(new
FactoryModuleBuilder().build(SingletonsFactory.class));
}
});
assertSame(injector.getInstance(ASingleton.class),
injector.getInstance(ASingleton.class));
assertSame(injector.getInstance(ASingleton.class),
injector.getInstance(SingletonsFactory.class).getSingleton());
}
}
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
You received this message because you are subscribed to the Google Groups
"google-guice-dev" 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-dev?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.