Skip to content

Commit 19384fe

Browse files
authored
Synchronize access to CT Wrapper (#517)
1 parent 9ef33f0 commit 19384fe

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

AndroidSDKCore/src/main/java/com/leanplum/internal/RequestSender.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,16 @@ public void sendRequests() {
143143
int statusCode = op.getResponseCode();
144144

145145
if (statusCode >= 200 && statusCode <= 299) {
146-
if (MigrationManager.refreshStateMidSession(responseBody)) { // TODO if current multi response contains getMigrateState this line would cause a second call, because getMigrateState response wouldn't be parsed yet
147-
Log.i("Migration state will be refreshed.");
148-
}
149-
150146
if (RequestUtil.updateApiConfig(responseBody)) {
151147
// API config is changed and we need to send requests again
152148
sendRequests();
153149
return;
154150
}
155151

152+
if (MigrationManager.refreshStateMidSession(responseBody)) {
153+
Log.i("Migration state will be refreshed.");
154+
}
155+
156156
// Parse response body and trigger callbacks
157157
invokeCallbacks(responseBody);
158158

AndroidSDKCore/src/main/java/com/leanplum/migration/MigrationManager.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ object MigrationManager {
1717

1818
@JvmStatic
1919
var wrapper: IWrapper = NullWrapper
20+
@Synchronized get
2021
private set
2122

2223
@JvmStatic
@@ -27,6 +28,7 @@ object MigrationManager {
2728
}
2829

2930
@JvmStatic
31+
@Synchronized
3032
fun updateWrapper() {
3133
if (Constants.isNoop()) {
3234
wrapper = NullWrapper
@@ -87,8 +89,6 @@ object MigrationManager {
8789
fetchStateAsync { success ->
8890
if (success) {
8991
// transition side effects are handled in fetchStateAsync
90-
} else {
91-
// TODO guard against continuous failure?
9292
}
9393
}
9494
return true

0 commit comments

Comments
 (0)