fix: close #I95OW7

This commit is contained in:
Michael Yang 2024-03-05 18:28:46 +08:00
parent 9356905a73
commit 2e548a621a
2 changed files with 5 additions and 4 deletions

View File

@ -51,7 +51,8 @@ class ModifyAttrsRecordHandler implements MethodHandler {
return proxyMethod.invoke(self, args);
}
updates.put(property, args[0]);
// fw.getField().getName() 的原因是 property 可能获取的内容不正确比如 ID 会得到的内容为 iD
updates.put(fw == null ? property : fw.getField().getName(), args[0]);
}
return proxyMethod.invoke(self, args);

View File

@ -51,12 +51,12 @@ public class FieldWrapper {
synchronized (clazz) {
fieldWrapper = wrapperMap.get(fieldName);
if (fieldWrapper == null) {
Field findField = ClassUtil.getFirstField(clazz, field -> field.getName().equals(fieldName));
Field findField = ClassUtil.getFirstField(clazz, field -> field.getName().equalsIgnoreCase(fieldName));
if (findField == null) {
throw new IllegalStateException("Can not find field \"" + fieldName + "\" in class: " + clazz.getName());
}
String setterName = "set" + StringUtil.firstCharToUpperCase(fieldName);
String setterName = "set" + StringUtil.firstCharToUpperCase(findField.getName());
Method setter = ClassUtil.getFirstMethod(clazz, method ->
method.getParameterCount() == 1
&& Modifier.isPublic(method.getModifiers())
@ -74,7 +74,7 @@ public class FieldWrapper {
fieldWrapper.setterMethod = setter;
String[] getterNames = new String[]{"get" + StringUtil.firstCharToUpperCase(fieldName), "is" + StringUtil.firstCharToUpperCase(fieldName)};
String[] getterNames = new String[]{"get" + StringUtil.firstCharToUpperCase(findField.getName()), "is" + StringUtil.firstCharToUpperCase(findField.getName())};
fieldWrapper.getterMethod = ClassUtil.getFirstMethod(clazz, method -> method.getParameterCount() == 0
&& Modifier.isPublic(method.getModifiers())
&& ArrayUtil.contains(getterNames, method.getName()));