diff --git a/org.springframework.web/src/main/java/org/springframework/web/util/UriTemplate.java b/org.springframework.web/src/main/java/org/springframework/web/util/UriTemplate.java index b4c0b6fdf8e..c9afae78e63 100644 --- a/org.springframework.web/src/main/java/org/springframework/web/util/UriTemplate.java +++ b/org.springframework.web/src/main/java/org/springframework/web/util/UriTemplate.java @@ -96,7 +96,7 @@ public class UriTemplate implements Serializable { */ public URI expand(Map uriVariables) { Assert.notNull(uriVariables, "'uriVariables' must not be null"); - Object[] values = new String[this.variableNames.size()]; + Object[] values = new Object[this.variableNames.size()]; for (int i = 0; i < this.variableNames.size(); i++) { String name = this.variableNames.get(i); if (!uriVariables.containsKey(name)) { diff --git a/org.springframework.web/src/test/java/org/springframework/web/util/UriTemplateTests.java b/org.springframework.web/src/test/java/org/springframework/web/util/UriTemplateTests.java index 7c7c07833a2..6eb3c534b61 100644 --- a/org.springframework.web/src/test/java/org/springframework/web/util/UriTemplateTests.java +++ b/org.springframework.web/src/test/java/org/springframework/web/util/UriTemplateTests.java @@ -70,6 +70,16 @@ public class UriTemplateTests { assertEquals("Invalid expanded template", new URI("http://example.com/hotels/1/bookings/42"), result); } + @Test + public void expandMapNonString() throws Exception { + Map uriVariables = new HashMap(2); + uriVariables.put("booking", 42); + uriVariables.put("hotel", 1); + UriTemplate template = new UriTemplate("http://example.com/hotels/{hotel}/bookings/{booking}"); + URI result = template.expand(uriVariables); + assertEquals("Invalid expanded template", new URI("http://example.com/hotels/1/bookings/42"), result); + } + @Test(expected = IllegalArgumentException.class) public void expandMapInvalidAmountVariables() throws Exception { UriTemplate template = new UriTemplate("http://example.com/hotels/{hotel}/bookings/{booking}");