-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Closed
Copy link
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: bugA general bugA general bug
Milestone
Description
Rune Lien opened SPR-7667 and commented
The API on the RestTemplate is misleading when it comes to variable passing
When Map<String,?> is used you would expect it to be possible to send an impl of HashMap<String,Integer> without any issues , but since expand of URI code is
Object[] values = new String[this.variableNames.size()];
for (int i = 0; i < this.variableNames.size(); i++) {
String name = this.variableNames.get(i);
if (!uriVariables.containsKey(name)) {
throw new IllegalArgumentException("'uriVariables' Map has no value for '" + name + "'");
}
values[i] = uriVariables.get(name);
}
you cannot ever send anything else but String.
The API should in my opinion be e.g
public <T> T getForObject(String url, Class<T> responseType, Map<String, ?> urlVariables) ---> public <T> T getForObject(String url, Class<T> responseType, Map<String, String> urlVariables)
To make it clear that String is the only allowed parameter value and to make impl take care of String conversion.
Affects: 3.0.4
Referenced from: commits a37a9e8
Metadata
Metadata
Assignees
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: bugA general bugA general bug