springfox: Endpoints with the same path and parameters but different headers some times cause java.lang.IllegalArgumentException: Multiple entries with same key
I am using version 2.7.0 and i am experiencing an erratic behavior where sometimes my application fails to start with the following error:
java.lang.IllegalArgumentException: Multiple entries with same key: springfox.documentation.spring.web.plugins.PathAndParametersEquivalence@50d2ab9.wrap(springfox.documentation.spring.web.WebMvcRequestHandler@4df57fa4)=[springfox.documentation.spring.web.WebMvcRequestHandler@4df57fa4] and springfox.documentation.spring.web.plugins.PathAndParametersEquivalence@50d2ab9.wrap(springfox.documentation.spring.web.WebMvcRequestHandler@844c806)=[springfox.documentation.spring.web.WebMvcRequestHandler@844c806] at com.google.common.collect.ImmutableMap.checkNoConflict(ImmutableMap.java:150) at com.google.common.collect.RegularImmutableMap.checkNoConflictInBucket(RegularImmutableMap.java:104) at com.google.common.collect.RegularImmutableMap.<init>(RegularImmutableMap.java:70) at com.google.common.collect.ImmutableMap$Builder.build(ImmutableMap.java:254) at com.google.common.collect.ImmutableListMultimap.copyOf(ImmutableListMultimap.java:268) at com.google.common.collect.ImmutableMultimap.copyOf(ImmutableMultimap.java:298) at com.google.common.collect.ImmutableMultimap$Builder.build(ImmutableMultimap.java:272) at com.google.common.collect.ImmutableListMultimap$Builder.build(ImmutableListMultimap.java:224) at com.google.common.collect.Multimaps.index(Multimaps.java:1511) at com.google.common.collect.Multimaps.index(Multimaps.java:1455) at springfox.documentation.spring.web.plugins.DefaultRequestHandlerCombiner.combined(DefaultRequestHandlerCombiner.java:59) at springfox.documentation.spring.web.plugins.DefaultRequestHandlerCombiner.combine(DefaultRequestHandlerCombiner.java:49) at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.defaultContextBuilder(DocumentationPluginsBootstrapper.java:106) at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.buildContext(DocumentationPluginsBootstrapper.java:91) at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.start(DocumentationPluginsBootstrapper.java:154) at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:175) ... 22 more
Debugging led me to pinpoint the issue to 2 mappings:
@ApiOperation(value = "foo by bar", hidden = true) @postmapping(path = "/foo/{bar}")
and
@ApiOperation(value = "new foo by bar", nickname = "new_foo_bar") @postmapping(path = "/foo/{bar}", headers = {"some_header"})
In #1894 I was pointed out that PathAndParametersEquivalence is supposed to just compare path and parameters ignoring the headers, so I would like to know how to proceed to avoid this?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 39 (12 by maintainers)
Tested the current version: 2.7.1-SNAPSHOT. It works like you describe: 2 errors at start, but the application started fine. So it’s better! Thanks @dilipkrish
Here the logs, when I started jhipster-registry:
@dilipkrish With 2.7.1-SNAPSHOT, it will print an error message instead of throw the exception:
But I believe the right fix is to change:
to:
@dhamudeva I am using 2.6.1 without problems while i wait for this issue to be fixed