From 8ee6c4a7aaa44df6d0bd80fdeb3573363f31a537 Mon Sep 17 00:00:00 2001 From: Sergii Karpenko Date: Thu, 16 Apr 2020 00:49:38 +0300 Subject: [PATCH] #186 IllegalStateException on Duplicate Method Key Parameter --- .../java/reactivefeign/allfeatures/AllFeaturesApi.java | 1 + .../reactivefeign/allfeatures/AllFeaturesController.java | 8 +++++--- .../java/reactivefeign/allfeatures/AllFeaturesFeign.java | 8 +++++++- .../java/reactivefeign/allfeatures/AllFeaturesMvc.java | 6 ++++++ .../java/reactivefeign/allfeatures/AllFeaturesTest.java | 8 ++++++++ .../spring/mvc/allfeatures/AllFeaturesMvc.java | 6 ++++++ 6 files changed, 33 insertions(+), 4 deletions(-) diff --git a/feign-reactor-core/src/test/java/reactivefeign/allfeatures/AllFeaturesApi.java b/feign-reactor-core/src/test/java/reactivefeign/allfeatures/AllFeaturesApi.java index 3adc7d2de..ff828d3a1 100644 --- a/feign-reactor-core/src/test/java/reactivefeign/allfeatures/AllFeaturesApi.java +++ b/feign-reactor-core/src/test/java/reactivefeign/allfeatures/AllFeaturesApi.java @@ -54,6 +54,7 @@ Mono> mirrorListHeaders( Mono>> mirrorMultiMapHeaders( Map> headerMap); + Mono mirrorHeaderAndRequestWithSameName(String header, String requestParam); Mono mirrorBody(String body); diff --git a/feign-reactor-core/src/test/java/reactivefeign/allfeatures/AllFeaturesController.java b/feign-reactor-core/src/test/java/reactivefeign/allfeatures/AllFeaturesController.java index 0bcce2094..71a856416 100644 --- a/feign-reactor-core/src/test/java/reactivefeign/allfeatures/AllFeaturesController.java +++ b/feign-reactor-core/src/test/java/reactivefeign/allfeatures/AllFeaturesController.java @@ -16,14 +16,11 @@ package reactivefeign.allfeatures; -import feign.Param; -import feign.RequestLine; import org.reactivestreams.Publisher; import org.springframework.util.MultiValueMap; import org.springframework.web.bind.annotation.RestController; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; -import reactor.core.scheduler.Schedulers; import java.nio.ByteBuffer; import java.time.Duration; @@ -108,6 +105,11 @@ public Mono>> mirrorMultiMapHeaders( throw new UnsupportedOperationException(); } + @Override + public Mono mirrorHeaderAndRequestWithSameName(String header, String requestParam) { + return just(new String[]{header, requestParam}); + } + @Override public Mono> mirrorMultiMapHeaders( //Spring can't treat Map> correctly diff --git a/feign-reactor-core/src/test/java/reactivefeign/allfeatures/AllFeaturesFeign.java b/feign-reactor-core/src/test/java/reactivefeign/allfeatures/AllFeaturesFeign.java index 6bb6c0934..f82553959 100644 --- a/feign-reactor-core/src/test/java/reactivefeign/allfeatures/AllFeaturesFeign.java +++ b/feign-reactor-core/src/test/java/reactivefeign/allfeatures/AllFeaturesFeign.java @@ -77,10 +77,16 @@ Mono> mirrorListHeaders( @Override @RequestLine("GET /mirrorMultiMapHeaders") - @Headers({ "Method-Header: {headerValue}" }) Mono>> mirrorMultiMapHeaders( @HeaderMap Map> headerMap); + @Override + @RequestLine("GET /mirrorHeaderAndRequestWithSameName") + @Headers({ "username: {headerValue}" }) + Mono mirrorHeaderAndRequestWithSameName( + @Param("headerValue") String header, + @Param("username") String requestParam); + @Override @RequestLine("POST " + "/mirrorBody") Mono mirrorBody(String body); diff --git a/feign-reactor-core/src/test/java/reactivefeign/allfeatures/AllFeaturesMvc.java b/feign-reactor-core/src/test/java/reactivefeign/allfeatures/AllFeaturesMvc.java index d5b3201a7..2cdd10b48 100644 --- a/feign-reactor-core/src/test/java/reactivefeign/allfeatures/AllFeaturesMvc.java +++ b/feign-reactor-core/src/test/java/reactivefeign/allfeatures/AllFeaturesMvc.java @@ -73,6 +73,12 @@ Mono> mirrorMultiMapHeaders( //Spring can't treat Map> correctly @RequestHeader MultiValueMap param); + @Override + @GetMapping(path = "/mirrorHeaderAndRequestWithSameName") + Mono mirrorHeaderAndRequestWithSameName( + @RequestHeader("username") String header, + @RequestParam("username") String requestParam); + @Override @PostMapping(path = "/mirrorBody") Mono mirrorBody(@RequestBody String body); diff --git a/feign-reactor-core/src/test/java/reactivefeign/allfeatures/AllFeaturesTest.java b/feign-reactor-core/src/test/java/reactivefeign/allfeatures/AllFeaturesTest.java index 2d8bb11fd..987495301 100644 --- a/feign-reactor-core/src/test/java/reactivefeign/allfeatures/AllFeaturesTest.java +++ b/feign-reactor-core/src/test/java/reactivefeign/allfeatures/AllFeaturesTest.java @@ -241,6 +241,14 @@ public void shouldReturnAllPassedMultiMapHeaders() { assertThat(toLowerCaseKeys(returned)).containsAllEntriesOf(toLowerCaseKeys(headersMap)); } + @Test + public void shouldReturnHeaderAndRequestParameter() { + String[] returned = client.mirrorHeaderAndRequestWithSameName("1", "2") + .subscribeOn(testScheduler()).block(); + + assertThat(returned).containsExactly("1", "2"); + } + @Test public void shouldReturnBody() { String returned = client.mirrorBody("Test Body") diff --git a/feign-reactor-test/feign-reactor-spring-mvc-test/src/test/java/reactivefeign/spring/mvc/allfeatures/AllFeaturesMvc.java b/feign-reactor-test/feign-reactor-spring-mvc-test/src/test/java/reactivefeign/spring/mvc/allfeatures/AllFeaturesMvc.java index ffa2813d9..f88564861 100644 --- a/feign-reactor-test/feign-reactor-spring-mvc-test/src/test/java/reactivefeign/spring/mvc/allfeatures/AllFeaturesMvc.java +++ b/feign-reactor-test/feign-reactor-spring-mvc-test/src/test/java/reactivefeign/spring/mvc/allfeatures/AllFeaturesMvc.java @@ -80,6 +80,12 @@ Mono> mirrorListHeaders( Mono>> mirrorMultiMapHeaders( @RequestHeader Map> param); + @Override + @GetMapping(path = "/mirrorHeaderAndRequestWithSameName") + Mono mirrorHeaderAndRequestWithSameName( + @RequestHeader("username") String header, + @RequestParam("username") String requestParam); + @Override @PostMapping(path = "/mirrorBody") Mono mirrorBody(@RequestBody String body);