-
Notifications
You must be signed in to change notification settings - Fork 117
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
Should not parse LocalDate
s from number (timestamp) -- or at least should have an option preventing
#58
Comments
No mechanism to prevent that currently; integers are accepted by default for all date/time types (so change for 2.9, if it didn't work on 2.8) is more due to unifying handling than otherwise intended change. But come to think of it now, it is not actually clear that numbers should work for As to blocking value you will need to register a custom deserializer that does this. |
Just thought I would mention the change in behavior to see if it was intended or not. I can work around it on my end if needed. Feel free to close if you don't plan on changing the behavior. |
@billoneil Looks like this was due to #20 actually, so it was intentional. Although perhaps bit misguided, considering the part. However! I do have one possibly useful idea wrt 2.9.x, your specific use case: there is property It is some work but it seems to me like a good way to do this -- my intent going forward is to limit number of on/off feature flags that are type-specific, and |
LocalDate
s from number (timestamp)
LocalDate
s from number (timestamp)LocalDate
s from number (timestamp) -- or at least should have an option preventing
I think that there should be a way to prevent this, but I am not sure what the correct path would be. |
What about the format Shape idea mentioned previously?
|
@kupci I go back and forth here, since for many date/time values integer representations ("timestamps") seem like a legit use case. But for specific case of So, yes, if you could do a patch that blocks this if strict (not lenient) that'd be good. Now, this would be great to get in 2.10 -- time is getting bit tight, release by 25th. :) |
It turns out this bug is already partially fixed. The leniency check is already in the LocalDateDeserializer:
As for the Shape of Now one question - for the Shape, I see the constructor signatures were changed to add that setting, which of course I can follow for the Deserializer, maybe just LocalDateDeserializer as it doesn't need to be any higher at this point. However, I also notice that in the Serializer hierarchy, it is accessible already, as you can see it retrieved in the JSR310FormattedSerialzerBase.createContextual method:
So maybe that's a cleaner way to go, but I don't see that same capability in the Deserializer hierarchy. |
I agree that it would probably make sense to add a shared helper method in base class for deserializers too. I do not remember the history here, but in the past serializers only were affected (to select one of many representations), whereas deserializers were always "lenient" thereby not caring too much about intended shape. At least for datatypes; there may have been some exceptions. So probably it just wasn't felt it was needed. But now is. |
It's there (the |
@kupci Sounds good. I'm happy with the progress made here -- thank you very much for your fixes. |
Quick note: due to 2.10.0 release, now needs to go to 2.11 branch for 2.11.0, as it is behavioral change and could break legit usage: something to avoid in a patch. |
In Jackson 2.8.x I had a unit test that parsed the following and expected an exception.
As of 2.9 related to this commit https://github.com/FasterXML/jackson-modules-java8/pull/22/files#diff-a1552641fab3c9690f2c8b0f5ee2fe89R102 it now parses as
1970-05-04
Is there a way to turn this off if I expect my dates to come in as a different format? I don't want to parse random integers as dates when it should be invalid input.
The text was updated successfully, but these errors were encountered: