-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
StdDateFormat
deserializes dates with no tz/offset as UTC instead of configured timezone
#1657
Comments
Hmmh. Date value with no specified timezone is... asking for trouble. Change between versions is unfortunate, but since no test failures were observed, this has been in effect unspecified behavior. |
Luckily we had tests for that on our side ;-) We relied on this behaviour since long to transfer so-called Local DateTime values. Since dates were reconstructed in the local timezone set on the mapper, they could safely be used eventhough they had a TZ associated with them. Even if that use case doesn't seem 100% valid, this change will affect many people and most won't notice it before production. I suspect the change is caused by the fix related to the handling of the 'zulu' dates... I haven't check yet. God feeling is both cases go through the same path... |
@brenuart Yes, seems likely it is related to that fix unfortunately. JDK's One thing that could help here is that a test and fix could result in release of |
I have to leave work now, but can be back in a couple of hours. I don't know about your timezone (lol)... A micro-patch would be great indeed. I can have a look at your existing tests and see if some of ours could be added... What timeframe do you expect ? |
@brenuart this does not affect me directly, and I have not seen reports by others yet, so I think timeline is really up to you. Typically adoption for later patches is kind of slow, too, which is good in this particular case. So, whenever you get a chance is great. My timezone is PST (Seattle, USA) fwtw. Btw, I appreciate your help: date/time handling is a royal PITA and it is not my area of expertise. |
Do you already know how to fix this issue or should I have a look?
I agree with you, date handling is a nightmare. I'm not an expert either (and certainly don't want to become one) - I just spent the last weeks fixing stuff so applications built with java util date, Joda or Java8 Time could work together without too much hassle... Hence the bunch of tests we have.
Oh, and I'm in GMT+1...
|
I just had a look at the Date deserialisation tests... They are nearly all built with the expected date in GMT, i.e. the default TZ of the mapper. None cover the case where the mapper may be configured with another time zone. Most should probably be rewritten to make use of an ObjectMapper configured with a timezone other than the default UTC. This way we would have the guarantee the configured timezone is actually taken into account in every scenarios. I'm working on this. Expect a first PR soon so we can continue the discussion on something more concrete. I need some sleep now... |
Oh shoot. Yes, I can see where this occurs, and had I spent bit more time with the patch this would have been obvious. Handling for no-timezone case does indeed just plop |
StdDateFormat
deserializes dates with no tz/offset as UTC instead of configured timezone
@brenuart I found the problem, and as far as I can see, fixed it. I added one simpleish test, but obviously that's not great coverage yet. Also turns out that I almost got change right: comment I had added was correct, but timezone I passed wrong... however: trying to reuse same format for two cases is trying to be too clever and so I split it into 2 separate cases. This should avoid potential problems with thread-safety too, which were present after first change (due to lazy instantiation, first access would "win"). |
PR #1657 created with additional test cases. |
@cowtowncoder Any chance we could release |
@brenuart I could do that relatively soon -- I am hoping for a fix or two, for some reason getting lots of reports now. Could do one before leaving for vacation on saturday. |
Prior to version
2.8.9
, dates without time zone or time offset (eg1970-01-01T00:00:00.000
) were deserialised in the TimeZone set on the ObjectMapper.Starting from
2.8.9
, these dates are deserialised inUTC
- which is a major (breaking) change in behaviour...Example:
The text was updated successfully, but these errors were encountered: