In class HttpRequestExecutingMessageHandler we declare (and add to the conversionService) an anonymous converter, which converts a Class to a String. This works for Spring 3.1.2.RELEASE - but Spring 3.0.7 wants to do an Object-to-String conversion instead.
Reason:
In 3.1.2.RELEASE:
class ReflectivePropertyAccessor#read {
.... return new TypedValue(value, typeDescriptor.narrow(value));
}
In 3.0.7.RELEASE:
class ReflectivePropertyAccessor#read {
.... return new TypedValue(((Method) member).invoke(target), typeDescriptor);
}
The narrow method is new in Spring 3.1. What happens is basically that the TypeDescriptor for Message.getPayload points to java.lang.Object. In 3.1, Spring does a bit of "fine-tuning", sees that the actually returned value is of type java.lang.Class and uses that instead.
Solution:
I have refactored out the anonymous converter class and added an additional converter:
private class ClassToStringConverter implements Converter<Class<?>, String> {
public String convert(Class<?> source) {
return source.getName();
}
}
private class ObjectToStringConverter implements Converter<Object, String> {
public String convert(Object source) {
if (source instanceof Class) {
return ((Class<?>) source).getName();
}
return source.toString();
}
}
Gunnar Hillert opened INT-2694 and commented
Affects: 2.2 M4 Sprint 2
This issue is a sub-task of #6666
Issue Links:
Add SpEL support to map the expected-response from ResponseEntity to HTTP outbound gateway [INT-1759] #5753 Add SpEL support to map the expected-response from ResponseEntity to HTTP outbound gateway
HTTP Outbound Gateway http-method should be able to pick up http-method from Message or expression [INT-2397] #6382 HTTP Outbound Gateway http-method should be able to pick up http-method from Message or expression
The text was updated successfully, but these errors were encountered: