mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
修复BeanUtil.hasGetter没有跳过getClass方法的问题
This commit is contained in:
@@ -114,8 +114,11 @@ public class BeanUtil {
|
||||
if (ClassUtil.isNormalClass(clazz)) {
|
||||
for (Method method : clazz.getMethods()) {
|
||||
if (method.getParameterCount() == 0) {
|
||||
if (method.getName().startsWith("get") || method.getName().startsWith("is")) {
|
||||
return true;
|
||||
final String name = method.getName();
|
||||
if (name.startsWith("get") || name.startsWith("is")) {
|
||||
if(false == "getClass".equals(name)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -918,4 +918,11 @@ public class BeanUtilTest {
|
||||
userEntity.setSex(0);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user