Skip to content

Commit 83795e5

Browse files
authored
Merge pull request hehonghui#61 from yinyinnie/master
Fix thread safe issue on vivo and Motorola Android 12
2 parents a7650b8 + 3136483 commit 83795e5

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

library/src/main/java/org/simple/eventbus/EventBus.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,11 @@ private class EventDispatcher {
369369
*/
370370
void dispatchEvents(Object aEvent) {
371371
Queue<EventType> eventsQueue = mLocalEvents.get();
372-
while (eventsQueue.size() > 0) {
373-
deliveryEvent(eventsQueue.poll(), aEvent);
372+
if (eventsQueue != null) {
373+
EventType eventType;
374+
while ((eventType = eventsQueue.poll()) != null) {
375+
deliveryEvent(eventType, aEvent);
376+
}
374377
}
375378
}
376379

0 commit comments

Comments
 (0)