@Nonnull
    private List<Deliverable> drainPendingElements()
    {
        final List<Deliverable> result = new LinkedList<>();
        final Iterator<Deliverable> iter = pendingElements.iterator(); // Weakly consistent iterator.
        while (iter.hasNext()) {
            result.add(iter.next());
            iter.remove();
        }
        return Collections.unmodifiableList(result);
    }
Removes all elements that are queued to be delivered to the peer from the queue and returns them as an
unmodifiable collection.

@return An unmodifiable list of elements that are to be sent to the peer.
xmppserver/src/main/java/org/jivesoftware/openfire/http/HttpSession.java