mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
修复BeanUtil.hasGetter没有跳过getClass方法的问题
This commit is contained in:
parent
def6fe2b60
commit
a3f48ccb29
@ -12,6 +12,7 @@
|
|||||||
### 🐞Bug修复
|
### 🐞Bug修复
|
||||||
* 【crypto】 修复NoSuchMethodError未捕获问题(issue#2966@Github)
|
* 【crypto】 修复NoSuchMethodError未捕获问题(issue#2966@Github)
|
||||||
* 【poi 】 修复SXSSFWorkbook调用setComment时错位的问题(issue#I6MBS5@Gitee)
|
* 【poi 】 修复SXSSFWorkbook调用setComment时错位的问题(issue#I6MBS5@Gitee)
|
||||||
|
* 【core 】 修复BeanUtil.hasGetter没有跳过getClass方法的问题(issue#I6MBS5@Gitee)
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
# 5.8.15 (2023-03-09)
|
# 5.8.15 (2023-03-09)
|
||||||
|
@ -114,8 +114,11 @@ public class BeanUtil {
|
|||||||
if (ClassUtil.isNormalClass(clazz)) {
|
if (ClassUtil.isNormalClass(clazz)) {
|
||||||
for (Method method : clazz.getMethods()) {
|
for (Method method : clazz.getMethods()) {
|
||||||
if (method.getParameterCount() == 0) {
|
if (method.getParameterCount() == 0) {
|
||||||
if (method.getName().startsWith("get") || method.getName().startsWith("is")) {
|
final String name = method.getName();
|
||||||
return true;
|
if (name.startsWith("get") || name.startsWith("is")) {
|
||||||
|
if(false == "getClass".equals(name)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -918,4 +918,11 @@ public class BeanUtilTest {
|
|||||||
userEntity.setSex(0);
|
userEntity.setSex(0);
|
||||||
Assert.assertTrue(BeanUtil.isCommonFieldsEqual(userDTO, userEntity, "age", "sex"));
|
Assert.assertTrue(BeanUtil.isCommonFieldsEqual(userDTO, userEntity, "age", "sex"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void hasGetterTest() {
|
||||||
|
// https://gitee.com/dromara/hutool/issues/I6M7Z7
|
||||||
|
final boolean b = BeanUtil.hasGetter(Object.class);
|
||||||
|
Assert.assertFalse(b);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user