Closed
Description
Furkan KAMACI opened SPR-8840 and commented
I have a model like that:
public class Wrapper<T> {
private String message;
private T data;
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
}
and I use resttemplate as follows:
...
Wrapper<Model> response = restTemplate.getForObject(URL, Wrapper.class, myMap);
Model model = response.getData();
...
However it throws a:
ClassCastException
I think resttemplate can not understand my generic variable and maybe it accepts it as an Object instead of generic T. So it becomes a LinkedHashMap.
Reference URL: http://forum.springsource.org/showthread.php?117511-RestTemplate-Can-Not-Convert-Generic-Types&p=387485#post387485
Issue Links:
- Proper handling of parameterized types in RestTemplate [SPR-7023] #11685 Proper handling of parameterized types in RestTemplate ("duplicates")