Skip to content

Commit 89fb595

Browse files
committed
Don't retry get params on thread interruption
If the app process is shutting down we don't want to keep retrying the remote params network request. No real world problem have been discovered but it's possible it could be create some unexpected states while the app process is being shutdown. In the context of our tests, this also fixes an issue where this retrying does not stop when we mock fail this network request. This oddly enough didn't seem to be an issue for the one pre-existing test using failGetParams but became a consistent test carry over issue when a 2nd test used this, which was added in the last commit.
1 parent c067ae4 commit 89fb595

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

OneSignalSDK/onesignal/src/main/java/com/onesignal/OneSignalRemoteParams.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,14 @@ public void run() {
139139
sleepTime = MAX_WAIT_BETWEEN_RETRIES;
140140

141141
OneSignal.Log(OneSignal.LOG_LEVEL.INFO, "Failed to get Android parameters, trying again in " + (sleepTime / 1_000) + " seconds.");
142-
OSUtils.sleep(sleepTime);
143-
androidParamsRetries++;
144-
makeAndroidParamsRequest(appId, userId, callback);
142+
try {
143+
Thread.sleep(sleepTime);
144+
androidParamsRetries++;
145+
makeAndroidParamsRequest(appId, userId, callback);
146+
} catch (InterruptedException e) {
147+
// Don't retry if something intentionally wants to stop this action
148+
e.printStackTrace();
149+
}
145150
}
146151
}, "OS_PARAMS_REQUEST").start();
147152
}

0 commit comments

Comments
 (0)