-
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
Fix handling of Time values out of UnixNano range #804
Conversation
Fixes #737, #803. Time values are encoded by storing the UnixNano representation, but this fails when the value of UnixNano is out of int64 range, see docs: https://golang.org/pkg/time/#Time.UnixNano > The result is undefined if the Unix time in nanoseconds cannot be represented by an int64 (a date before the year 1678 or after 2262) Fix this by storing values outside of UnixNano range as-is rather than using UnixNano with a new Field type.
Codecov Report
@@ Coverage Diff @@
## master #804 +/- ##
=======================================
Coverage 98.31% 98.31%
=======================================
Files 43 43
Lines 2311 2315 +4
=======================================
+ Hits 2272 2276 +4
Misses 32 32
Partials 7 7
Continue to review full report at Codecov.
|
zapcore/field_test.go
Outdated
@@ -164,6 +165,10 @@ func TestFields(t *testing.T) { | |||
} | |||
|
|||
func TestEquals(t *testing.T) { | |||
timeOutOfRange := time.Unix(0, math.MaxInt64).Add(time.Nanosecond) | |||
timeOutOfRangeNano := time.Unix(0, timeOutOfRange.UnixNano()) |
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.
We should try out of range in both directions.
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.
👍 done
Co-Authored-By: Abhinav Gupta <[email protected]>
Co-Authored-By: Abhinav Gupta <[email protected]>
Fixes uber-go#737, uber-go#803. Time values are encoded by storing the UnixNano representation, but this fails when the value of UnixNano is out of int64 range, see docs: https://golang.org/pkg/time/#Time.UnixNano > The result is undefined if the Unix time in nanoseconds cannot be represented by an int64 (a date before the year 1678 or after 2262) Fix this by storing values outside of UnixNano range as-is rather than using UnixNano with a new Field type.
Fixes uber-go#737, uber-go#803. Time values are encoded by storing the UnixNano representation, but this fails when the value of UnixNano is out of int64 range, see docs: https://golang.org/pkg/time/#Time.UnixNano > The result is undefined if the Unix time in nanoseconds cannot be represented by an int64 (a date before the year 1678 or after 2262) Fix this by storing values outside of UnixNano range as-is rather than using UnixNano with a new Field type.
Fixes #737, #803.
Time values are encoded by storing the UnixNano representation, but this
fails when the value of UnixNano is out of int64 range, see docs:
https://golang.org/pkg/time/#Time.UnixNano
Fix this by storing values outside of UnixNano range as-is rather
than using UnixNano with a new Field type.