-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[MBL-960] Fix crash by using default hashing and equality for the config #1850
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1850 +/- ##
=======================================
Coverage 84.59% 84.59%
=======================================
Files 1276 1276
Lines 116026 116017 -9
Branches 30892 30888 -4
=======================================
- Hits 98155 98149 -6
+ Misses 16788 16786 -2
+ Partials 1083 1082 -1
... and 2 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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.
Yea nice clean up.
Library/Format.swift
Outdated
@@ -403,7 +403,7 @@ public enum Format { | |||
|
|||
public let defaultThresholdInDays = 30 // days | |||
|
|||
internal struct DateFormatterConfig { | |||
internal struct DateFormatterConfig: Hashable, Equatable { |
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.
Cool, yea let's do this - according to the documentation - Hashable
conformance requires Equatable
, so you probably only need Hashable
.
https://developer.apple.com/documentation/swift/hashable
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.
Cool, I'll delete the explicit Equatable. Thanks!
2c669bc
to
939482b
Compare
939482b
to
924181b
Compare
📲 What
Update the date formatter to conform to
Hashable
andEquatable
by default instead of having custom implementations. This has the effect of also relying on thedateFormat
when comparing twoDateFormatterConfig
objects.Also add a test that fails without these changes and passes now that the caching is fixed.
🤔 Why
Currently, when the
dateFormat
is ignored in comparisons, when we try to parse a different date format, we fetch a cached one expecting a different format, leading to a crash. This happens any time we try to create a formatter for a config that has a different date format but is otherwise identical to a formatter that's already been cached. Specifically, this happens when we show the creator tools deprecation banner and also show credit card expiration dates without killing the app in-between.👀 See
JIRA ticket
✅ Acceptance criteria