From 0b496cbffef4d75d07b2e9709328c7d6b172afd7 Mon Sep 17 00:00:00 2001 From: Alan Young Date: Wed, 5 Apr 2017 16:52:49 +0100 Subject: Fix PresenceOracle initialization of PriorityQueue with initial size 0. Change-Id: I624ede83351e2901272173f775d4f098743183b3 diff --git a/src/com/isode/stroke/presence/PresenceOracle.java b/src/com/isode/stroke/presence/PresenceOracle.java index e983d51..f1710a6 100644 --- a/src/com/isode/stroke/presence/PresenceOracle.java +++ b/src/com/isode/stroke/presence/PresenceOracle.java @@ -199,10 +199,14 @@ public class PresenceOracle { * @return The relevant presence. */ public static Presence getActivePresence(Collection presences) { + + PresenceAccountCmp comparator = new PresenceAccountCmp(); + int size = presences.size(); + if (size < 1) size = 1; - PriorityQueue online = new PriorityQueue(presences.size(),new PresenceAccountCmp()); - PriorityQueue away = new PriorityQueue(presences.size(),new PresenceAccountCmp()); - PriorityQueue offline = new PriorityQueue(presences.size(),new PresenceAccountCmp()); + PriorityQueue online = new PriorityQueue(size, comparator); + PriorityQueue away = new PriorityQueue(size, comparator); + PriorityQueue offline = new PriorityQueue(size, comparator); for (Presence presence : presences) { switch (presence.getShow()) { -- cgit v0.10.2-6-g49f6