-
-
Notifications
You must be signed in to change notification settings - Fork 682
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
FieldUtils.readField returns static fields #2000
Comments
Hi @henri-tremblay, I would not expect Or did I misunderstand your example? I tried to run the example on 3.14 and 3.17.2, both fail with:
Ignoring static fields could be a separate topic, but right now I cannot see how the assertion would verify the value of |
A does implement map in my case. But it goes out before that. Let me get back with a full example. I apologize, I did it a bit too quickly from an actual issue I had in my code. |
I was able to reproduce the case you mentioned, the root cause is probably #1763. I am not sure we should entirely ignore static fields as this could prevent the verification of non public values.
Maybe it could be reasonable to ignore static fields during 2 and try them only if 3 failed. @joel-costigliola thoughts? |
I think we should ignore static fields by default, |
I agree with @joel-costigliola. |
My only concern is that Or we would need to do a bigger refactoring to make sure only |
For recursive comparison, the intent was not to check static fields, for extracting I would argue the same. |
I agree, static field verification is really a corner case. Ok, I can drop the bad 👮♂️ hat! |
Fixed in 2f3eeb9. |
Summary
The issue came from
hasFieldOrPropertyWithValue
.FieldUtils.readField
will consider values from static fields to be what we are looking for. I think static fields should be ignored.This behavior is new. This test used to work in 3.14 and doesn't in 3.17.
Example
The text was updated successfully, but these errors were encountered: