diff --git a/docs/pom.xml b/docs/pom.xml
index 25c59597..5125edd7 100644
--- a/docs/pom.xml
+++ b/docs/pom.xml
@@ -15,7 +15,7 @@
spring-cloud-openfeign
${basedir}/..
- 2.0.x
+ 2.0.x,2.1.x
diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/FeignUtils.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/FeignUtils.java
index af24d7ac..db2247d2 100644
--- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/FeignUtils.java
+++ b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/FeignUtils.java
@@ -56,7 +56,8 @@ public final class FeignUtils {
static Collection addTemplateParameter(Collection possiblyNull,
String paramName) {
- Collection params = ofNullable(possiblyNull).orElse(new ArrayList<>());
+ Collection params = ofNullable(possiblyNull).map(ArrayList::new)
+ .orElse(new ArrayList<>());
params.add(String.format("{%s}", paramName));
return params;
}
diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringMvcContractTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringMvcContractTests.java
index 3efdad96..fed0b6c0 100644
--- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringMvcContractTests.java
+++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringMvcContractTests.java
@@ -523,6 +523,18 @@ public class SpringMvcContractTests {
this.contract.parseAndValidateMetadata(method.getDeclaringClass(), method);
}
+ @Test
+ public void testAddingTemplatedParameterWithTheSameKey()
+ throws NoSuchMethodException {
+ Method method = TestTemplate_Advanced.class.getDeclaredMethod(
+ "testAddingTemplatedParamForExistingKey", String.class);
+ MethodMetadata data = contract
+ .parseAndValidateMetadata(method.getDeclaringClass(), method);
+
+ assertThat(data.template().headers().get("Accept")).contains("application/json",
+ "{Accept}");
+ }
+
public interface TestTemplate_Simple {
@RequestMapping(value = "/test/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@@ -645,6 +657,10 @@ public class SpringMvcContractTests {
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
TestObject getTest();
+ @GetMapping(produces = "application/json")
+ String testAddingTemplatedParamForExistingKey(
+ @RequestHeader("Accept") String accept);
+
}
public interface TestTemplate_DateTimeFormatParameter {