-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
修复ognl表达式获取字段值返回类型错误 #2965
base: master
Are you sure you want to change the base?
修复ognl表达式获取字段值返回类型错误 #2965
Conversation
请问这个问题在哪个版本修复了啊?我也遇到这个问题了 |
目前还没 |
这个可以加些测试不? |
已加 |
public Object getPossibleProperty(Map context, Object target, String name) throws OgnlException { | ||
Object result; | ||
try { | ||
result = OgnlRuntime.getFieldValue((OgnlContext) context, target, name, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个修复貌似不合理。原始的 ognl是支持对 getter 函数用 .
去访问的。比如有一个 getName
,可以用 xxx.name
去获取。 这个修改会导致原来的 OgnlRuntime.getMethodValue
的尝试没有了。
另外,直接用 OgnlRuntime.getFieldValue
可能在高版本的 jdk 会有问题。
由于
ObjectPropertyAccessor
会优先尝试调用字段的get方法或read方法(例如名称为hasXXX的方法),有时候这些方法并不会直接返回字段值,导致无法查看对象的某些字段,例如org.apache.kafka.clients.consumer.internals.Fetcher
,查看字段completedFetches
返回的是一个boolean类型