修复JsonUtil.toBean泛型数组类型丢失问题(pr#3876@Github)

This commit is contained in:
Looly 2025-03-03 12:32:58 +08:00
parent 9b19bf84a8
commit 0585b3c6b7
2 changed files with 6 additions and 7 deletions

View File

@ -73,8 +73,6 @@ public class ValueProviderToBeanCopier<T> extends AbsCopier<ValueProvider<String
return;
}
// 获取目标字段真实类型
final Type fieldType = TypeUtil.getActualType(this.targetType ,propDesc.getFieldType());
// 编辑键值对
final MutableEntry<Object, Object> entry = copyOptions.editField(tFieldName, null);
if(null == entry){
@ -89,6 +87,8 @@ public class ValueProviderToBeanCopier<T> extends AbsCopier<ValueProvider<String
if(!source.containsKey(tFieldName)){
return;
}
// 获取目标字段真实类型
final Type fieldType = TypeUtil.getActualType(this.targetType ,propDesc.getFieldType());
final Object sValue = source.value(tFieldName, fieldType);
// 检查目标对象属性是否过滤属性

View File

@ -85,14 +85,13 @@ public class ActualTypeMapperPool {
public static Type getActualType(final Type type, final GenericArrayType genericArrayType) {
final Map<Type, Type> typeTypeMap = get(type);
Type actualType = typeTypeMap.get(genericArrayType);
if (actualType == null) {
// 获取泛型数组元素泛型对应的确切类型
final Type componentType = typeTypeMap.get(genericArrayType.getGenericComponentType());
if (!(componentType instanceof Class<?>)) {
return null;
if (componentType instanceof Class) {
actualType = ArrayUtil.getArrayType((Class<?>) componentType);
typeTypeMap.put(genericArrayType, actualType);
}
actualType = ArrayUtil.getArrayType((Class<?>) componentType);
typeTypeMap.put(genericArrayType, actualType);
}
return actualType;