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

Duplicate Modules Cause Injector Creation Failure #65

Open
cielowu opened this issue Mar 31, 2021 · 2 comments
Open

Duplicate Modules Cause Injector Creation Failure #65

cielowu opened this issue Mar 31, 2021 · 2 comments

Comments

@cielowu
Copy link

cielowu commented Mar 31, 2021

Hi,

So I'm bumping our system to Dropwizard 2.x, dropwizard-guice causes an issue because the (jersey2-guice)[https://github.com/HubSpot/dropwizard-guice] still uses prior Jersey 2.6 version.

So I'm trying to migrate from dropwizard-guice to this to give it a try. However, duplicate modules cause the creation failure of the Injector.

After digging it a little bit, this is because now the default InjectorFactory implementation uses Modules.combine to combine all the modules. This makes the uniqueness check inside LifecycleInjectorBuilderImpl.java that we use essentially become ineffective.

public interface InjectorFactory {
  Injector create(Stage stage, Module module);

  default Injector create(Stage stage, Iterable<? extends Module> modules) {
    return create(stage, Modules.combine(modules));
  }
}
@jhaber
Copy link
Member

jhaber commented Mar 31, 2021

Oof sorry about that. Since implementors of InjectorFactory only accept a single module, it's a bit hard to change at this point. For now you can work around the issue by supplying a custom InjectorFactory which doesn't use Modules.combine

@cielowu
Copy link
Author

cielowu commented Mar 31, 2021

Yes, that does unblock the issue.

Now I face the same issue as dropwizard-guice, do you know what is the plan for supporting Dropwizard 2.x?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants