diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c2c028f3..a9cdec212 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ------------------------------------------------------------------------------------------------------------- -# 5.8.13.M1 (2023-02-21) +# 5.8.13.M1 (2023-02-22) ### 🐣新特性 ### 🐞Bug修复 @@ -15,6 +15,7 @@ * 【core 】 修复ReUtil.delAll方法当 content 仅为空格时的问题(issue#I6GIMT@Gitee) * 【core 】 修复Tailer文件内容跟随在调用stop后,文件依旧被占用问题(issue#I6GFD2@Gitee) * 【core 】 修复ReflectUtil.invokeRaw方法中参数类型转换动作未生效的问题(pr#2912@Github) +* 【core 】 修复isXXX转换时的匹配问题(issue#I6H0XF@Gitee) ------------------------------------------------------------------------------------------------------------- diff --git a/hutool-core/src/main/java/cn/hutool/core/bean/copier/MapToBeanCopier.java b/hutool-core/src/main/java/cn/hutool/core/bean/copier/MapToBeanCopier.java index aba1bc571..47d08ded4 100755 --- a/hutool-core/src/main/java/cn/hutool/core/bean/copier/MapToBeanCopier.java +++ b/hutool-core/src/main/java/cn/hutool/core/bean/copier/MapToBeanCopier.java @@ -114,17 +114,6 @@ public class MapToBeanCopier extends AbsCopier, T> { // 转驼峰尝试查找 sKeyStr = StrUtil.toCamelCase(sKeyStr); propDesc = targetPropDescMap.get(sKeyStr); - if(null != propDesc){ - return propDesc; - } - - // boolean类型参数名转换尝试查找 - if(sKeyStr.startsWith("is")){ - sKeyStr = StrUtil.removePreAndLowerFirst(sKeyStr, 2); - propDesc = targetPropDescMap.get(sKeyStr); - return propDesc; - } - - return null; + return propDesc; } } diff --git a/hutool-core/src/test/java/cn/hutool/core/bean/BeanUtilTest.java b/hutool-core/src/test/java/cn/hutool/core/bean/BeanUtilTest.java index f79d72d96..dace87dc1 100755 --- a/hutool-core/src/test/java/cn/hutool/core/bean/BeanUtilTest.java +++ b/hutool-core/src/test/java/cn/hutool/core/bean/BeanUtilTest.java @@ -248,8 +248,10 @@ public class BeanUtilTest { final SubPersonWithAlias subPersonWithAlias = BeanUtil.toBean(map, SubPersonWithAlias.class); Assert.assertEquals("sub名字", subPersonWithAlias.getSubName()); - Assert.assertTrue(subPersonWithAlias.isBooleana()); - Assert.assertEquals(true, subPersonWithAlias.getBooleanb()); + + //https://gitee.com/dromara/hutool/issues/I6H0XF + Assert.assertFalse(subPersonWithAlias.isBooleana()); + Assert.assertNull(subPersonWithAlias.getBooleanb()); } @Test diff --git a/hutool-json/src/test/java/cn/hutool/json/IssueI6H0XFTest.java b/hutool-json/src/test/java/cn/hutool/json/IssueI6H0XFTest.java new file mode 100644 index 000000000..983b654cc --- /dev/null +++ b/hutool-json/src/test/java/cn/hutool/json/IssueI6H0XFTest.java @@ -0,0 +1,19 @@ +package cn.hutool.json; + +import lombok.Data; +import org.junit.Assert; +import org.junit.Test; + +public class IssueI6H0XFTest { + @Test + public void toBeanTest(){ + final Demo demo = JSONUtil.toBean("{\"biz\":\"A\",\"isBiz\":true}", Demo.class); + Assert.assertEquals("A", demo.getBiz()); + Assert.assertEquals("{\"biz\":\"A\"}", JSONUtil.toJsonStr(demo)); + } + + @Data + static class Demo { + String biz; + } +}