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
Duplicate serializations occur for inherited getters #59
Comments
mikejhill
added a commit
to mikejhill/json-view
that referenced
this issue
Jul 13, 2018
Recursion for detection of inherited properties is already done by getAccessibleProperties and is no longer needed in the writeObject method.
monitorjbl
added a commit
that referenced
this issue
Jul 13, 2018
Remove redundant recursion for serialization (#59)
monitorjbl
added a commit
that referenced
this issue
Jul 13, 2018
So the unit tests I had in place were designed to operate on a I'll push out 1.0.1 tonight, this bug is bad enough that I don't want to sit on it. |
1.0.1 should be available now on Maven Central. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It looks like #46 produced a bug for serialization when getter methods are inherited. Take the following class structure as an example:
Serializing an instance of class
C
will produce a result similar to the following:{"id": 0", "id": 0", "id": 0}
.Sorry, I'm not able to drill down to the exact cause for this, but it looks like the library is now traversing the class hierarchy multiple times. When serializing, the library searches each level of the class hierarchy for accessible properties. However, all inherited properties are included as well when searching for accessible properties. In the example above, this means that serialization of an instance of
C
writesgetId()
once when serializing properties forC
, once when serializing properties forB
, and finally once when serializing the properties ofA
for a total of three times.My best guess is that this worked fine when just using declared fields (before #46) since inherited fields weren't checked.
Removing the additional class hierarchy traversal seems to fix the issue in my limited testing.
The text was updated successfully, but these errors were encountered: