Skip to content

Commit a37a9e8

Browse files
committed
SPR-7667
1 parent 577755d commit a37a9e8

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

org.springframework.web/src/main/java/org/springframework/web/util/UriTemplate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public List<String> getVariableNames() {
9696
*/
9797
public URI expand(Map<String, ?> uriVariables) {
9898
Assert.notNull(uriVariables, "'uriVariables' must not be null");
99-
Object[] values = new String[this.variableNames.size()];
99+
Object[] values = new Object[this.variableNames.size()];
100100
for (int i = 0; i < this.variableNames.size(); i++) {
101101
String name = this.variableNames.get(i);
102102
if (!uriVariables.containsKey(name)) {

org.springframework.web/src/test/java/org/springframework/web/util/UriTemplateTests.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ public void expandMap() throws Exception {
7070
assertEquals("Invalid expanded template", new URI("http://example.com/hotels/1/bookings/42"), result);
7171
}
7272

73+
@Test
74+
public void expandMapNonString() throws Exception {
75+
Map<String, Integer> uriVariables = new HashMap<String, Integer>(2);
76+
uriVariables.put("booking", 42);
77+
uriVariables.put("hotel", 1);
78+
UriTemplate template = new UriTemplate("http://example.com/hotels/{hotel}/bookings/{booking}");
79+
URI result = template.expand(uriVariables);
80+
assertEquals("Invalid expanded template", new URI("http://example.com/hotels/1/bookings/42"), result);
81+
}
82+
7383
@Test(expected = IllegalArgumentException.class)
7484
public void expandMapInvalidAmountVariables() throws Exception {
7585
UriTemplate template = new UriTemplate("http://example.com/hotels/{hotel}/bookings/{booking}");

0 commit comments

Comments
 (0)