I'm trying to create a CSV message converter to use with the Spring
message converters but I'm not able to configure the support(Class<?> clazz)
method when clazz
is of type Collection
. Basically my REST
endpoint is returning a Collection
of objects directly and not wrapped inside another object.
Using reflection, the only thing I'm able to get as the type of the Collection
is E
which obviously doesn't give me much to work with.
I've tried manually and also with helper tools like TypeUtils.genericArrayType(clazz)
from Apache Commons
. The only work around I can think of is to just always return true and verify the type inside the writeInternal(Object o, HttpOutputMessage message)
method.
Is this a bug in the implementation of the AbstractMessageConverterMethodProcessor
class that retrieves the return type of the endpoint or am I missing something?
By the way, this is the method that returns the type in the Spring implementation?
protected Class<?> getReturnValueType(Object value, MethodParameter returnType) {
return (value != null ? value.getClass() : returnType.getParameterType());
}
Aucun commentaire:
Enregistrer un commentaire