Skip to content

Commit

Permalink
修复ConverterRegistry中无效加载导致的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
looly committed Dec 27, 2022
1 parent 379b10b commit 200c098
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
* 【core 】 修复UrlBuilder中参数中包括"://"判断错误问题(pr#898@Gitee)
* 【core 】 修复IndexedComparator导致的数据错乱问题(ExcelWriter使用部分别名导致字段丢失)(issue#I66Z6B@Gitee)
* 【crypto】 修复sm2构造方法NullPointerException(pr#2820@Github)
* 【core 】 修复ConverterRegistry中无效加载导致的问题(issue#2812@Github)

-------------------------------------------------------------------------------------------------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import cn.hutool.core.lang.Opt;
import cn.hutool.core.lang.TypeReference;
import cn.hutool.core.map.SafeConcurrentHashMap;
import cn.hutool.core.util.ClassLoaderUtil;
import cn.hutool.core.util.ClassUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.ReflectUtil;
Expand Down Expand Up @@ -280,12 +279,6 @@ public <T> T convert(Type type, Object value, T defaultValue, boolean isCustomFi

// 尝试转Bean
if (BeanUtil.isBean(rowType)) {
try {
// 由于5.x设计缺陷,JSON转bean无法实现自定义转换,因此此处临时使用反射方式获取自定义的转换器,此问题会在6.x中彻底解决。
final Class<?> clazz = ClassLoaderUtil.loadClass("cn.hutool.json.BeanConverterForJSON");
return ((Converter<T>)ReflectUtil.newInstance(clazz, type)).convert(value, defaultValue);
}catch (final Throwable ignore){
}
return new BeanConverter<T>(type).convert(value, defaultValue);
}

Expand Down

0 comments on commit 200c098

Please sign in to comment.