Skip to content

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

Open

Description

@mcculls

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.

Activity

  1. added a commit that references this issue on May 17, 2024
    8226b25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions