Skip to content

Commit 3136483

Browse files
committed
Fix thread safe issue on vivo and Motorola Android 12
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Object.hashCode()' on a null object reference at j$.util.concurrent.ConcurrentHashMap.get() at j$.util.concurrent.ConcurrentHashMap.containsKey() at org.simple.eventbus.EventBus$EventDispatcher.getMatchedEventTypes(EventBus.java:393) at org.simple.eventbus.EventBus$EventDispatcher.deliveryEvent(EventBus.java:363) at org.simple.eventbus.EventBus$EventDispatcher.dispatchEvents(EventBus.java:351) at org.simple.eventbus.EventBus.post(EventBus.java:189)
1 parent a7650b8 commit 3136483

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)