Skip to content

Commit 9e2d4ab

Browse files
authored
LIBMOBILE-1076: Fix NPE Crash due a race condition. (#118) (#119)
1 parent 7fe17db commit 9e2d4ab

File tree

1 file changed

+10
-2
lines changed
  • core/src/main/java/com/segment/analytics/kotlin/core/platform/plugins

1 file changed

+10
-2
lines changed

core/src/main/java/com/segment/analytics/kotlin/core/platform/plugins/StartupQueue.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,16 @@ class StartupQueue : Plugin, Subscriber {
6464

6565
private fun replayEvents() {
6666
// replay the queued events to the instance of Analytics we're working with.
67-
while(!queuedEvents.isEmpty()) {
68-
analytics.process(queuedEvents.poll())
67+
while (!queuedEvents.isEmpty()) {
68+
69+
val event = queuedEvents.poll()
70+
71+
// It is possible that event might actually be null due to time-slicing
72+
// after checking if the queue is empty so we only process if the event
73+
// if it is indeed not NULL.
74+
event?.let {
75+
analytics.process(it)
76+
}
6977
}
7078
}
7179
}

0 commit comments

Comments
 (0)