-
-
Notifications
You must be signed in to change notification settings - Fork 138
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
Fix getNullValue of IonValueDeserializer. #319
Conversation
… reading and return java null for IonNulls
@cowtowncoder Can you add @popematt as reviewer? |
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.
The code itself is fine in that it does exactly what you say it does. However, I am concerned about the proposed solution for deserializing nulls (#318). This is technically a backwards-incompatible change that you're introducing, which means that it can't be merged into in any 2.x branch.
Can you make the new behavior opt-in through some sort of configuration?
Actually what I am proposing is to fix backward compatibility. After #296, 2.13 already became incompatible. Just take this simple test case below. @Test
public void shouldBeAbleToDeserializeJavaNullValue() throws Exception {
IonValueData source = new IonValueData();
source.put("c", null);
IonValue data = ION_VALUE_MAPPER.writeValueAsIonValue(source);
IonValueData result = ION_VALUE_MAPPER.readValue(data, IonValueData.class);
assertEquals(source, result);
} The problem defined in issue #295 was about |
@atokuzAmzn Thank you for explaining that; this makes sense to me now. @cowtowncoder, should this be merged into the 2.13 branch as well as 2.14? |
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.
It might be useful for to add a unit test that's something like this just to make it absolutely clear how Java null
and Ion null
/null.null
should interact with each other in this context.
IonValueData source = new IonValueData();
source.put("a", null);
source.put("b", ion("null"));
IonValue data = ION_VALUE_MAPPER.writeValueAsIonValue(source);
IonValueData result = ION_VALUE_MAPPER.readValue(data, IonValueData.class);
IonValueData expected = new IonValueData();
expected.put("a", null);
expected.put("b", null);
assertEquals(expected, result);
…l/null.null should interact with each other
@popematt I have added an extra test case |
Hmmmh. Ok, so the previous change went into 2.13.0, sort of establishing 2.13 behavior. But if everyone else feels strongly I would not block inclusion in 2.13 instead. |
I believe we need to fix the current behaviour in 2.13 since it digressed from 2.12. |
As I said, if others (@popematt ) agree, I am ok changing it to 2.13. I am just saying that for users who might have started with 2.13.0, change in behavior in a patch might be surprising. Just let me know either way. Also noted: besides myself, @mcliedtke has commit access. And I can give more access to Amazon Ion team members if anyone is interested. While I like being kept in the loop I also want to delegate access rights where it can help speed up things. |
@atokuzAmzn The Ion specification allows |
…n reading un-annotated untyped nulls
@tgregg I have added another check to implement your first option and also added a new unit test case while expanding the existing null deserialization test case with annotations. |
To me, the 2.13 behavior seems like the right handling for Ion nulls. An I realize this is different from 2.12, but the 2.13 just seems more correct. I'd potentially be open to a feature flag that allows a user to specify the legacy behavior if there was a simple way. |
This is moving into a deadlock:) And I think it was my mistake trying to solve two issues (#317 and #318) with one PR. Because as far as I can understand most of the discussion revolves around #318, but I could actually create a separate PR for #317 to solve that separately. So back to #318. I accept that the last commit made it confusing. But as far as I understand there can never be a full solution to this problem. So we have to make a trade off. Either, Whatever we choose, we will still make a wrong deserialization. There is no escape from this. Even if we make this configurable we will still need a default value. And I believe the answer to this question lies in which use case occurs more often than the other. I am not an expert at all in this but I believe serializing java nulls probably occurs much more often than serializing IonNulls. And just to add as confirmation, in the internal implementation which we were using for a long time, the choice was to return java nulls for both of them. |
In my last comment I glossed over #317, I agree that #317 should be fixed. For #318, I think the current 2.13 behavior is the most correct when it comes to the intent of what an
I agree there is ambiguity with respect to the following case:
With a default If a user wanted to remove the ambiguity of Java vs. Ion nulls, I would likely direct them to serialize Java-null as an absent value:
This would remove all ambiguity around what the desired effect was. The serialized data can be deserialized without data loss.
Ideally I wouldn't want frequency to determine the behavior, rather what would be most intuitive or correct for the data specification. Given the intent of |
And just to make it clear: I am happy to merge whatever is agreed upon by maintainers, but it may be simplest for @mcliedtke to merge. The only (?) caveat is that whoever merges PRs also needs to ensure they get forward-merged to later branches as appropriate (2.13 -> 2.14 -> master). |
Now that #317 is resolved, what would be the way forward here, if any? No particular hurry but wanted to add an update if there might be progress. At minimum if PR is to stay open would probably need to merge/rebase from 2.14 as there's currently conflict (for overlapping work I presume). |
I agree with @mcliedtke 's assessment and suggested workaround (using |
In the end, we needed to make a choice so I am also OK to close this issue. |
This PR aims to resolve the issues #317 and #318
Changes: