-
Notifications
You must be signed in to change notification settings - Fork 17
Description
This issue was created automatically with bugzilla2github
Bugzilla Bug 456633
Date: 2015-01-04 16:55:02 -0500
From: Stuart McCulloch <mcculls@gmail.com>
To: Project Inbox <sisu-inbox@eclipse.org>
Last updated: 2015-01-04 16:55:02 -0500
Comment 2501804
Date: 2015-01-04 16:55:02 -0500
From: Stuart McCulloch <mcculls@gmail.com>
When running multiple tests with BeanScanning.CACHE (which caches and re-uses elements to save setup time) and AssistedInject factories, the following exception can occur:
com.google.inject.CreationException: Unable to create injector, see the following errors:
1) Factories.create() factories may only be used in one Injector!
at com.google.inject.assistedinject.FactoryProvider2.class(FactoryProvider2.java:86)
at com.google.inject.assistedinject.FactoryProvider2.initialize(FactoryProvider2.java:577)
at ClassRealm[plexus.core, parent: null] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule -> org.eclipse.sisu.space.SpaceModule$1 -> org.sonatype.nexus.repository.internal.RepositoryModule -> com.google.inject.assistedinject.FactoryModuleBuilder$1)
1 error
at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:448)
at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:176)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:110)
at com.google.inject.Guice.createInjector(Guice.java:96)
at com.google.inject.Guice.createInjector(Guice.java:73)
at com.google.inject.Guice.createInjector(Guice.java:62)
The recommended workaround is to use BeanScanning.INDEX which is almost as fast as the CACHE setting, but doesn't suffer from cache-related issues like the above exception.
To support AssistedInject properly with BeanScanning.CACHE we'll need to reset the affected factory elements, just like we did with the private lookup elements in bug #429366.