Skip to content

Commit 1e9d01b

Browse files
committed
fix: Fixes NPE on reconnect.
We saw that in the brewery connection, but it can happen and for the client connection to the room. java.lang.NullPointerException: Cannot invoke "Object.hashCode()" because "key" is null at java.base/java.util.concurrent.ConcurrentHashMap.replaceNode(ConcurrentHashMap.java:1111) at java.base/java.util.concurrent.ConcurrentHashMap.remove(ConcurrentHashMap.java:1102) at org.jivesoftware.smackx.disco.ServiceDiscoveryManager.removeNodeInformationProvider(ServiceDiscoveryManager.java:387) at net.java.sip.communicator.impl.protocol.jabber.ScServiceDiscoveryManager.stop(ScServiceDiscoveryManager.java:680) at net.java.sip.communicator.impl.protocol.jabber.ProtocolProviderServiceJabberImpl.disconnectAndCleanConnection(ProtocolProviderServiceJabberImpl.java:1529) at net.java.sip.communicator.impl.protocol.jabber.ProtocolProviderServiceJabberImpl.unregisterInternal(ProtocolProviderServiceJabberImpl.java:1581) at net.java.sip.communicator.impl.protocol.jabber.ProtocolProviderServiceJabberImpl.unregisterInternal(ProtocolProviderServiceJabberImpl.java:1559) at net.java.sip.communicator.impl.protocol.jabber.ProtocolProviderServiceJabberImpl.unregister(ProtocolProviderServiceJabberImpl.java:1541) at net.java.sip.communicator.plugin.reconnectplugin.PPReconnectWrapper.unregister(PPReconnectWrapper.java:365) at net.java.sip.communicator.plugin.reconnectplugin.PPReconnectWrapper.reconnect(PPReconnectWrapper.java:348) at net.java.sip.communicator.plugin.reconnectplugin.PPReconnectWrapper.registrationStateChanged(PPReconnectWrapper.java:219) Null is EntityCapsManager.currentCapsVersion and that is initialized on any CapabilitiesChanged, and EntityCapsManager always add a feature when enableEntityCaps is called. enableEntityCaps is called before adding the listener for CapabilitiesChanged and the add feature is executed in a blocking thread.
1 parent c02c32c commit 1e9d01b

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/main/java/org/jitsi/jigasi/JvbConference.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -424,11 +424,6 @@ private ExtensionElement addSupportedFeatures(
424424
*/
425425
private final ChatRoomPresenceListener presenceListener = new ChatRoomPresenceListener();
426426

427-
/**
428-
* The features for the current xmpp provider we will use later adding to the room presence we send.
429-
*/
430-
private ExtensionElement features = null;
431-
432427
/**
433428
* Whether we are currently joining as a visitor.
434429
*/
@@ -750,9 +745,6 @@ private synchronized void setXmppProvider(
750745

751746
this.xmppProvider = xmppProvider;
752747

753-
// Advertise gateway features before joining and if possible before connecting
754-
this.features = addSupportedFeatures(xmppProvider.getOperationSet(OperationSetJitsiMeetToolsJabber.class));
755-
756748
xmppProvider.addRegistrationStateChangeListener(this);
757749

758750
this.telephony
@@ -1022,7 +1014,10 @@ public void joinConferenceRoom()
10221014
chatRoom.addPresencePacketExtensions(initiator);
10231015
}
10241016

1025-
chatRoom.addPresencePacketExtensions(this.features);
1017+
// we want to add the features just before joining and after connecting
1018+
// to make sure EntityCapsManager.currentCapsVersion is properly initialized
1019+
chatRoom.addPresencePacketExtensions(
1020+
addSupportedFeatures(xmppProvider.getOperationSet(OperationSetJitsiMeetToolsJabber.class)));
10261021

10271022
String statsId = JigasiBundleActivator.getConfigurationService().getString(STATS_ID_PNAME);
10281023
if (StringUtils.isNotEmpty(statsId))

src/main/java/org/jitsi/jigasi/xmpp/CallControlMucActivator.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818
package org.jitsi.jigasi.xmpp;
1919

20+
import static org.jitsi.jigasi.util.Util.*;
2021
import static org.jivesoftware.smack.packet.StanzaError.Condition.internal_server_error;
2122

2223
import net.java.sip.communicator.impl.protocol.jabber.*;
@@ -34,6 +35,7 @@
3435
import org.jivesoftware.smack.bosh.*;
3536
import org.jivesoftware.smack.iqrequest.*;
3637
import org.jivesoftware.smack.packet.*;
38+
import org.jivesoftware.smackx.disco.*;
3739
import org.jxmpp.jid.parts.*;
3840
import org.osgi.framework.*;
3941

@@ -301,6 +303,9 @@ private void joinCommonRoom(ProtocolProviderService pps)
301303
conn.registerIQRequestHandler(new HangUpIqHandler(pps));
302304

303305
connectionResource = conn.getUser().getResourceOrNull();
306+
307+
// to make sure EntityCapsManager.currentCapsVersion is properly initialized
308+
ServiceDiscoveryManager.getInstanceFor(conn).addFeature(JIGASI_FEATURE_NAME);
304309
}
305310

306311
OperationSetMultiUserChat muc = pps.getOperationSet(OperationSetMultiUserChat.class);

0 commit comments

Comments
 (0)