Skip to content

Commit

Permalink
#186 IllegalStateException on Duplicate Method Key Parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergii Karpenko committed Apr 15, 2020
1 parent 88dd9fd commit 8ee6c4a
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Mono<List<Long>> mirrorListHeaders(
Mono<Map<String, List<String>>> mirrorMultiMapHeaders(
Map<String, List<String>> headerMap);

Mono<String[]> mirrorHeaderAndRequestWithSameName(String header, String requestParam);

Mono<String> mirrorBody(String body);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -108,6 +105,11 @@ public Mono<Map<String, List<String>>> mirrorMultiMapHeaders(
throw new UnsupportedOperationException();
}

@Override
public Mono<String[]> mirrorHeaderAndRequestWithSameName(String header, String requestParam) {
return just(new String[]{header, requestParam});
}

@Override
public Mono<MultiValueMap<String, String>> mirrorMultiMapHeaders(
//Spring can't treat Map<String, List<String>> correctly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,16 @@ Mono<List<Long>> mirrorListHeaders(

@Override
@RequestLine("GET /mirrorMultiMapHeaders")
@Headers({ "Method-Header: {headerValue}" })
Mono<Map<String, List<String>>> mirrorMultiMapHeaders(
@HeaderMap Map<String, List<String>> headerMap);

@Override
@RequestLine("GET /mirrorHeaderAndRequestWithSameName")
@Headers({ "username: {headerValue}" })
Mono<String[]> mirrorHeaderAndRequestWithSameName(
@Param("headerValue") String header,
@Param("username") String requestParam);

@Override
@RequestLine("POST " + "/mirrorBody")
Mono<String> mirrorBody(String body);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ Mono<MultiValueMap<String, String>> mirrorMultiMapHeaders(
//Spring can't treat Map<String, List<String>> correctly
@RequestHeader MultiValueMap<String, String> param);

@Override
@GetMapping(path = "/mirrorHeaderAndRequestWithSameName")
Mono<String[]> mirrorHeaderAndRequestWithSameName(
@RequestHeader("username") String header,
@RequestParam("username") String requestParam);

@Override
@PostMapping(path = "/mirrorBody")
Mono<String> mirrorBody(@RequestBody String body);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ Mono<List<Long>> mirrorListHeaders(
Mono<Map<String, List<String>>> mirrorMultiMapHeaders(
@RequestHeader Map<String, List<String>> param);

@Override
@GetMapping(path = "/mirrorHeaderAndRequestWithSameName")
Mono<String[]> mirrorHeaderAndRequestWithSameName(
@RequestHeader("username") String header,
@RequestParam("username") String requestParam);

@Override
@PostMapping(path = "/mirrorBody")
Mono<String> mirrorBody(@RequestBody String body);
Expand Down

0 comments on commit 8ee6c4a

Please sign in to comment.