Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ddec3dbd authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Check if priority queue is empty before attempting to get first element" into main

parents 70f92c49 04be6f6e
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -2439,6 +2439,13 @@ public final class MessageQueue {
    }

    private static Message first(ConcurrentSkipListSet<Message> queue) {
        // If the queue is empty, avoid calling queue.first() which will allocate
        // an exception that we'll immediately ignore.
        // We might race with another thread that's removing from the queue and
        // end up with the exception anyway, but at least we tried.
        if (queue.isEmpty()) {
            return null;
        }
        try {
            return queue.first();
        } catch (NoSuchElementException e) {