This is an automated email from the ASF dual-hosted git repository. liubao pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git
commit 284b3dd64bf92243169395e3df8d2c11e29f176b Author: liubao <[email protected]> AuthorDate: Mon Mar 30 17:37:33 2020 +0800 [SCB-1824]jacskon convertValue will convert all objects start for 2.10.*, java-chassis need not convert RestTemplate arguments --- .../foundation/common/utils/RestObjectMapper.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/RestObjectMapper.java b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/RestObjectMapper.java index cd2ceb2..7a57691 100644 --- a/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/RestObjectMapper.java +++ b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/RestObjectMapper.java @@ -84,7 +84,22 @@ public class RestObjectMapper extends AbstractRestObjectMapper { } @Override + @SuppressWarnings("unchecked") public <T> T convertValue(Object fromValue, JavaType toValueType) throws IllegalArgumentException { + // After jackson 2.10.*, will by pass the following check when convert value. But this is useful + // for java chassis applications and do not need to convert. So add the check here.(conversion is + // not necessary and will cause some trouble in some user applications that depend on this) + if (fromValue == null) { + return null; + } else { + Class<?> targetType = toValueType.getRawClass(); + if (targetType != Object.class + && !toValueType.hasGenericTypes() + && targetType.isAssignableFrom(fromValue.getClass())) { + return (T) fromValue; + } + } + return super.convertValue(fromValue, toValueType); } }
