From 1fd03c396a8935b81efa4bb238a93c60e0a97325 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Fri, 9 Mar 2018 16:00:18 +0100 Subject: [PATCH] Make Roster's non-roster presence second-level map bounded Fixes SMACK-809. --- .../src/main/java/org/jivesoftware/smack/roster/Roster.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java b/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java index 501d65023..94ab78210 100644 --- a/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java +++ b/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java @@ -382,12 +382,14 @@ public final class Roster extends Manager { private synchronized Map getOrCreatePresencesInternal(BareJid entity) { Map entityPresences = getPresencesInternal(entity); if (entityPresences == null) { - entityPresences = new ConcurrentHashMap<>(); if (contains(entity)) { + entityPresences = new ConcurrentHashMap<>(); presenceMap.put(entity, entityPresences); } else { - nonRosterPresenceMap.put(entity, entityPresences); + LruCache nonRosterEntityPresences = new LruCache<>(32); + nonRosterPresenceMap.put(entity, nonRosterEntityPresences); + entityPresences = nonRosterEntityPresences; } } return entityPresences;