-
Notifications
You must be signed in to change notification settings - Fork 817
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
#744 CompatibleFieldSerializer and fields declared as super-types #745
#744 CompatibleFieldSerializer and fields declared as super-types #745
Conversation
It was something failing in my test applications. I basically had multiple JARs built with different implementations of the same class to trigger the JVM crash. My final PR had all the required fixes. |
Thanks for the info @isaki! My implementation also prevents boxing, but it still sets the field's |
I was able to reproduce the test failures you mentioned @isaki. I never ran the tests before I added my condition to prevent boxing. When I remove the condition, a bunch of tests fail with "Read type is incompatible with the field type: int -> Integer" etc. So I guess we are good to go and can apply this PR. @magro: Please take a look. |
I actually think this might run into issues; in my original investigation setting value class even to the primitive type caused problems. Based on the "Files changed" tab you are assigning valueClass in all cases and then invoking the set method on the cachedField instance. I suspect that you have reintroduced the issues my checks intended to prevent. I could be wrong; it's been awhile since I looked at this. Unfortunately I no longer have the project that I used to generate these issues, however, it would not take me long to recreate. I shall endeavor to do so later today/tomorrow. I will test both my approach and yours to see if the things work correctly. If it turns out my paranoia wasn't required, all the better! |
That would be great! We can add the condition from your PR, but I would feel much more comfortable doing it because of a failing test-case. |
It is possible that this causes other issues, but not very likely because the fix applied by Nate also sets the |
I did not test against Nate's fixes, no; I had assumed he had. |
This is very time consuming, but the current release version has at least one bug. My test setup involved commenting in and out various lines to create 3 different jars. One used a I've pushed my work in progress code to here: https://github.com/isaki/kryo-jvm-test Kryo 5.0.0-RC7 Release
I believe that the current implementation is broken in that it is serializing a boxed value as a primitive. I double checked my build and ensured I was working with a boxed value. EDIT: This was simply to establish a baseline for the current released version. This testing is time consuming and I will test the proposed PR as well as my initial change tomorrow. |
@isaki: Thank you so much for your work! I can reproduce the bug you found, but I don't fully understand it yet. The value is clearly written as a I think we have to add a check for primitives and their wrapper types instead of simply checking if the classes are assignable. This would also support changes from |
I just pushed a better solution for this issue in 6e61f77 I completely removed the condition that checks for primitive classes when serializing and made the assignable check aware of primitive types and their wrappers. I also added a test that should guard against these issues in the future. |
…ndition for `valueClass`
bbe0aca
to
6e61f77
Compare
I'll build your patch and run my tests later this afternoon. |
My testing results show things look good except for one small case.
|
Thanks a lot for your work on fixing these issues, @theigl and @isaki! We are also hitting #744 and it prevents us from upgrading to the latest Kryo, even though it contains other fixes that we need. Could you please review this PR, @magro and @NathanSweet? Thanks! |
This PR attempts to resolve #744.
The original fix pushed by @NathanSweet in fb10f37 only works for fields that have the same type as the object stored in it. It fails for fields declared as super-types and interfaces.
This PR adds a check for primitive types originally proposed by @isaki in #670 and uses the concrete value class in all other instances.