Skip to content

Commit 9eae4fb

Browse files
committed
Change User State Method Synchronization
• In the previous commit, I wanted to explicitly use a sync lock object for different methods to synchronize on, to allow more fine-grained control over what parts of methods get synchronized • However, I mistakenly left out a method called getToSyncUserState(). • This commit removes the method synchronization and synchronizes on the syncLock, an instance property that other methods also use to synchronize on.
1 parent 84618a6 commit 9eae4fb

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,11 @@ protected JSONObject generateJsonDiff(JSONObject cur, JSONObject changedTo, JSON
119119
}
120120
}
121121

122-
protected synchronized UserState getToSyncUserState() {
123-
if (toSyncUserState == null)
124-
toSyncUserState = newUserState("TOSYNC_STATE", true);
122+
protected UserState getToSyncUserState() {
123+
synchronized (syncLock) {
124+
if (toSyncUserState == null)
125+
toSyncUserState = newUserState("TOSYNC_STATE", true);
126+
}
125127

126128
return toSyncUserState;
127129
}

0 commit comments

Comments
 (0)