-
Notifications
You must be signed in to change notification settings - Fork 8
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
MLIBZ-2719: Prevent multiple calls to refresh token #330
MLIBZ-2719: Prevent multiple calls to refresh token #330
Conversation
Kinvey/Kinvey/HttpRequest.swift
Outdated
if let user = self.credential as? User { | ||
user.logout() | ||
DispatchQueue.global(qos: .default).async { | ||
guard !client.refreshingToken else { |
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.
Is the client.refreshingToken
made thread-safe because it is being accessed and set from within the DispatchQueue
?
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.
right, so this is a serial queue and I'm calling wait()
on the DispatchGroup
so the combination of both makes the entire refresh token process thread-safe
…ppen right after the first request
Codecov Report
@@ Coverage Diff @@
## develop #330 +/- ##
===========================================
+ Coverage 86.3% 86.35% +0.05%
===========================================
Files 70 70
Lines 8431 8470 +39
===========================================
+ Hits 7276 7314 +38
- Misses 1155 1156 +1
Continue to review full report at Codecov.
|
Description
Prevent multiple calls to refresh token which was causing a race condition
Changes
User
,Client
andHttpRequest
operations are queued when a401
response is returnedTests