From f6b22189035650fd4319a9ff2d9335600f5e075d Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Fri, 9 Feb 2024 14:13:36 +0100 Subject: [PATCH] [roster] suppress "roster not loaded while processing presence" if self-presence Fixes SMACK-941. --- .../java/org/jivesoftware/smack/roster/Roster.java | 13 +++++++++++-- 1 file changed, 11 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 02ee0d7e1b..cb8563e0a0 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 @@ -1534,11 +1534,20 @@ public void processStanza(Stanza packet) throws NotConnectedException, Interrupt } } + + final Jid from = packet.getFrom(); + if (!isLoaded() && rosterLoadedAtLogin) { - LOGGER.warning("Roster not loaded while processing " + packet); + XMPPConnection connection = connection(); + + // Only log the warning, if this is not the reflected self-presence. Otherwise, + // the reflected self-presence may cause a spurious warning in case the + // connection got quickly shut down. See SMACK-941. + if (connection != null && !from.equals(connection.getUser())) { + LOGGER.warning("Roster not loaded while processing " + packet); + } } final Presence presence = (Presence) packet; - final Jid from = presence.getFrom(); final BareJid key; if (from != null) {