From 8708b7b01cf4f36524bff3dc9aa5a7a6534ce221 Mon Sep 17 00:00:00 2001 From: Alan Young Date: Fri, 3 Jun 2016 16:19:28 +0100 Subject: XMPPRosterImpl.getItems() needs to do deep copy. And (therefore) XMPPRosterItem needs a copy constructor. Change-Id: I9c4d833e559cf70d0c125fc6d841f16b8c2ce5b9 diff --git a/src/com/isode/stroke/roster/XMPPRosterImpl.java b/src/com/isode/stroke/roster/XMPPRosterImpl.java index d87a20e..7b80104 100644 --- a/src/com/isode/stroke/roster/XMPPRosterImpl.java +++ b/src/com/isode/stroke/roster/XMPPRosterImpl.java @@ -73,7 +73,11 @@ public class XMPPRosterImpl extends XMPPRoster { @Override public Collection getItems() { - return entries_.values(); + Collection items = new ArrayList(entries_.size()); + for (XMPPRosterItem item : entries_.values()) { + items.add(new XMPPRosterItem(item)); + } + return items; } @Override diff --git a/src/com/isode/stroke/roster/XMPPRosterItem.java b/src/com/isode/stroke/roster/XMPPRosterItem.java index 1412f83..25ebc47 100644 --- a/src/com/isode/stroke/roster/XMPPRosterItem.java +++ b/src/com/isode/stroke/roster/XMPPRosterItem.java @@ -5,6 +5,7 @@ package com.isode.stroke.roster; import java.util.Collection; +import java.util.ArrayList; import com.isode.stroke.elements.RosterItemPayload; import com.isode.stroke.jid.JID; @@ -21,6 +22,15 @@ public class XMPPRosterItem { this.groups = groups; this.subscription = subscription; } + + // Copy constructor + public XMPPRosterItem(XMPPRosterItem from) { + this(from.jid, from.name, null, from.subscription); + if (from.groups != null) { + groups = new ArrayList(from.groups.size()); + groups.addAll(from.groups); + } + } public final JID getJID() { return jid; -- cgit v0.10.2-6-g49f6