GH-562 Add type conversion documentation
Add test in AWS to showcase type conversion Fix AWS FunctionInvoker to delegate to effectively delegate type conversion to the native mechanism of spring-cloud-function Resolves #562
This commit is contained in:
@@ -77,8 +77,13 @@ public class JsonMessageConverter extends AbstractMessageConverter {
|
||||
}
|
||||
|
||||
Type convertToType = conversionHint == null ? targetClass : (Type) conversionHint;
|
||||
Object result = jsonMapper.fromJson(message.getPayload(), convertToType);
|
||||
return result;
|
||||
try {
|
||||
return this.jsonMapper.fromJson(message.getPayload(), convertToType);
|
||||
}
|
||||
catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,8 +23,6 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JavaType;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.type.TypeFactory;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
@@ -32,8 +30,6 @@ import org.apache.commons.logging.LogFactory;
|
||||
*/
|
||||
public class JacksonMapper extends JsonMapper {
|
||||
|
||||
private static Log logger = LogFactory.getLog(JsonMapper.class);
|
||||
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
public JacksonMapper(ObjectMapper mapper) {
|
||||
@@ -62,7 +58,7 @@ public class JacksonMapper extends JsonMapper {
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.warn("Failed to convert. Possible bug as the conversion probably shouldn't have been attampted here", e);
|
||||
throw new IllegalStateException("Failed to convert. Possible bug as the conversion probably shouldn't have been attampted here", e);
|
||||
}
|
||||
return convertedValue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user