-
Notifications
You must be signed in to change notification settings - Fork 376
bug: Handling race condition #2408
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
base: main
Are you sure you want to change the base?
Conversation
| // Check state and provide appropriate error messages | ||
| when (initState) { | ||
| InitState.FAILED -> { | ||
| throw IllegalStateException("Initialization failed. Cannot proceed.") | ||
| } | ||
| InitState.NOT_STARTED -> { | ||
| throw IllegalStateException("Must call 'initWithContext' before 'logout'") | ||
| } | ||
| InitState.IN_PROGRESS, InitState.SUCCESS -> { | ||
| // Continue - these states allow proceeding (will wait if needed) | ||
| } |
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.
Duplicate code, can we make a function for this?
|
|
||
| if (!initState.isSDKAccessible()) { | ||
| throw IllegalStateException("Must call 'initWithContext' before 'login'") | ||
| // Check state and provide appropriate error messages |
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.
Can isSDKAccessible() be changed to something like checkSDKAccessible() so that it throws proper error messages based on initState, and do nothing if allow proceeding?
| } | ||
| } | ||
|
|
||
| waitForInit() |
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 are essentially checking init state before and after waitForInit(). Should we let waitForInit() handle the throwing/proceeding based on the initState so we don't need to check for the state again in the usage?
Description
One Line Summary
Handling race condition during initWithContext
Details
Motivation
#2192 (comment)
To address this issue
Scope
Internal racecondition handling.
Testing
Unit testing
NA
Manual testing
Smoke tested the app
Affected code checklist
Checklist
Overview
Testing
Final pass
This change is