-
Notifications
You must be signed in to change notification settings - Fork 549
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
Mutithreading issues in cognitoIdentity CognitoUser #272
Mutithreading issues in cognitoIdentity CognitoUser #272
Conversation
…onInBackground, right now there might be a scenario where 10 threads call this function and all of them go over the network to get the new ID token after the 1hour expiry.
Codecov Report
@@ Coverage Diff @@
## master #272 +/- ##
=========================================
Coverage ? 6.79%
=========================================
Files ? 5009
Lines ? 193826
Branches ? 46509
=========================================
Hits ? 13163
Misses ? 179527
Partials ? 1136
Continue to review full report at Codecov.
|
Hello @nikhilshekhawat, Thanks for using our SDK and submitting a pull request. Can you resolve the conflicts and re-submit? Thanks |
Hi @nikhilshekhawat, Can you resolve the conflicts and re-submit the PR? |
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.
This looks like a good optimization
throw new CognitoNotAuthorizedException("User is not authenticated", nae); | ||
} catch (Exception e) { | ||
CognitoUser.semaphore.release(); |
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.
Since we are dealing with locking here, can you move the release into a finally block?
/** | ||
* The semaphore to provide mutex for the getSession call if called on multiple threads, this would avoid multiple threads going over the network and refreshing the tokens | ||
*/ | ||
public static Semaphore semaphore = new Semaphore(1, true); |
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 there a reason this is public? If not please change to private.
Addressing this PR changes in the next release. |
fixed bug for when multiple threads were calling CognitoUser.getSessionInBackground. Currently there might be a scenario where multiple threads call this function and all of them go over the network to get the new ID token after the 1hour expiry. This error is for aws-sdk version 2.4.
In earlier version of the same SDK if we made multiple calls to this function one of the threads would just fail and require user login. This error is for aws-sdk version 2.2.
http://stackoverflow.com/questions/43104955/aws-cognito-getsessioninbackground-fails-when-id-token-needs-refreshing