@@ -102,7 +102,7 @@ object MigrationManager {
102102 callback.invoke(false )
103103 }
104104
105- request.onResponse {
105+ request.onResponse { // onResponse is executed in parallel operation
106106 Log .d(" Migration state response: $it " )
107107 val responseData = ResponseHandler ().handleMigrateStateContent(it)
108108 if (responseData != null ) {
@@ -111,7 +111,9 @@ object MigrationManager {
111111 val newState = getState()
112112 handleStateTransition(oldState, newState)
113113 }
114- callback.invoke(true )
114+ OperationQueue .sharedInstance().addOperation { // use same operation queue as handleStateTransition
115+ callback.invoke(true )
116+ }
115117 }
116118
117119 RequestSender .getInstance().send(request)
@@ -133,7 +135,7 @@ object MigrationManager {
133135
134136 private fun handleStateTransition (oldState : MigrationState , newState : MigrationState ) {
135137 if (oldState.useLeanplum() && ! newState.useLeanplum()) {
136- OperationQueue .sharedInstance().addOperation {
138+ OperationQueue .sharedInstance().addOperation { // fetchState's callback is executed on the same operation queue
137139 // flush all saved data to LP
138140 RequestSender .getInstance().sendRequests()
139141 // delete LP data
@@ -143,7 +145,7 @@ object MigrationManager {
143145 }
144146
145147 if (! oldState.useCleverTap() && newState.useCleverTap()) {
146- OperationQueue .sharedInstance().addOperation {
148+ OperationQueue .sharedInstance().addOperation { // fetchState's callback is executed on the same operation queue
147149 // flush all saved data to LP, new data will come with the flag ct=true
148150 RequestSender .getInstance().sendRequests()
149151 // create wrapper
0 commit comments