-
Notifications
You must be signed in to change notification settings - Fork 1.7k
DUPLICATE_ELEMENT
Googler edited this page Aug 13, 2020
·
1 revision
Guice will throw a ProvisionException with DUPLICATE_ELEMENT error if:
- Duplicate values are added to a Multibinder that does not allow duplicates
- Duplicate keys are added to a MapBinder that does not allow duplicates
If the Multibinder or MapBinder should not have duplicate elements then this
error can be fixed by modifying the application code to prevent duplicate
elements from being added. The error message from Guice contains information on
what the duplicate values or keys are.
If it is expected that the Multibinder or MapBinder will have duplicates
values or keys, make sure that permitDuplicates is called when the
Multibinder or MapBinder is created:
final class FooModule extends AbstractModule {
@Override
protected void configure() {
Multibinder.newSetBinder(binder(), String.class)
.permitDuplicates();
MapBinder.newMapBinder(binder(), String.class, String.class)
.permitDuplicates();
}
}-
User's Guide
-
Integration
-
Extensions
-
Internals
-
Releases
-
Community