Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need to reset AssistedInject factory elements when using BeanScanning.CACHE (Bugzilla Bug 456633) #23

Open
mcculls opened this issue Oct 25, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@mcculls
Copy link
Contributor

mcculls commented Oct 25, 2021

This issue was created automatically with bugzilla2github

Bugzilla Bug 456633

Date: 2015-01-04 16:55:02 -0500
From: Stuart McCulloch <[email protected]>
To: Project Inbox <[email protected]>

Last updated: 2015-01-04 16:55:02 -0500

Comment 2501804

Date: 2015-01-04 16:55:02 -0500
From: Stuart McCulloch <[email protected]>

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.

@mcculls mcculls added the bug Something isn't working label Oct 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant