diff --git a/jicofo-common/src/main/java/org/jitsi/impl/protocol/xmpp/log/PacketDebugger.java b/jicofo-common/src/main/java/org/jitsi/impl/protocol/xmpp/log/PacketDebugger.java index bf48ec82d8..f8e9f2cf5b 100644 --- a/jicofo-common/src/main/java/org/jitsi/impl/protocol/xmpp/log/PacketDebugger.java +++ b/jicofo-common/src/main/java/org/jitsi/impl/protocol/xmpp/log/PacketDebugger.java @@ -17,6 +17,7 @@ import edu.umd.cs.findbugs.annotations.*; import org.jitsi.utils.logging2.*; +import org.jitsi.xmpp.util.*; import org.jivesoftware.smack.*; import org.jivesoftware.smack.debugger.*; import org.jivesoftware.smack.packet.*; @@ -66,13 +67,17 @@ public PacketDebugger(XMPPConnection connection, @NonNull String id) @Override public void onIncomingStreamElement(TopLevelStreamElement streamElement) { - logger.debug(() -> "RCV PKT (" + id + "): " + streamElement.toXML()); + logger.debug( + () -> "RCV PKT (" + id + "): " + XmlStringBuilderUtil.Companion.toStringOpt(streamElement.toXML()) + ); } @Override public void onOutgoingStreamElement(TopLevelStreamElement streamElement) { - logger.debug(() -> "SENT PKT (" + id + "): " + streamElement.toXML()); + logger.debug( + () -> "SENT PKT (" + id + "): " + XmlStringBuilderUtil.Companion.toStringOpt(streamElement.toXML()) + ); } // It's fine to do non-atomic as it's only 1 thread doing write operation diff --git a/jicofo-common/src/main/java/org/jitsi/jicofo/xmpp/BaseBrewery.java b/jicofo-common/src/main/java/org/jitsi/jicofo/xmpp/BaseBrewery.java index c763a1bea9..6354927105 100644 --- a/jicofo-common/src/main/java/org/jitsi/jicofo/xmpp/BaseBrewery.java +++ b/jicofo-common/src/main/java/org/jitsi/jicofo/xmpp/BaseBrewery.java @@ -20,6 +20,7 @@ import org.jetbrains.annotations.*; import org.jitsi.jicofo.xmpp.muc.*; import org.jitsi.utils.logging2.*; +import org.jitsi.xmpp.util.*; import org.jivesoftware.smack.*; import org.jivesoftware.smack.packet.*; import org.jxmpp.jid.*; @@ -303,7 +304,7 @@ protected void processInstanceStatusChanged(@NotNull EntityFullJid jid, @NotNull instance.status = extension; } - logger.debug("New presence from " + jid + ": " + extension.toXML()); + logger.debug(() -> "New presence from " + jid + ": " + XmlStringBuilderUtil.toStringOpt(extension)); onInstanceStatusChanged(jid, extension); } diff --git a/jicofo-common/src/main/kotlin/org/jitsi/jicofo/xmpp/Util.kt b/jicofo-common/src/main/kotlin/org/jitsi/jicofo/xmpp/Util.kt index 026a04e180..49af7f52ea 100644 --- a/jicofo-common/src/main/kotlin/org/jitsi/jicofo/xmpp/Util.kt +++ b/jicofo-common/src/main/kotlin/org/jitsi/jicofo/xmpp/Util.kt @@ -18,6 +18,7 @@ package org.jitsi.jicofo.xmpp import org.jitsi.utils.logging2.LoggerImpl +import org.jitsi.xmpp.util.XmlStringBuilderUtil.Companion.toStringOpt import org.jivesoftware.smack.AbstractXMPPConnection import org.jivesoftware.smack.SmackException import org.jivesoftware.smack.XMPPConnection @@ -61,9 +62,9 @@ fun parseJidFromClientProxyJid( fun XMPPConnection.tryToSendStanza(stanza: Stanza) = try { sendStanza(stanza) } catch (e: SmackException.NotConnectedException) { - logger.error("No connection - unable to send packet: " + stanza.toXML(), e) + logger.error("No connection - unable to send packet: ${stanza.toXML().toStringOpt()}", e) } catch (e: InterruptedException) { - logger.error("Failed to send packet: " + stanza.toXML().toString(), e) + logger.error("Failed to send packet: ${stanza.toXML().toStringOpt()}", e) } @Throws(SmackException.NotConnectedException::class) diff --git a/jicofo-common/src/main/kotlin/org/jitsi/jicofo/xmpp/jingle/JingleSession.kt b/jicofo-common/src/main/kotlin/org/jitsi/jicofo/xmpp/jingle/JingleSession.kt index ca6c5dfae9..4c3bf89ef1 100644 --- a/jicofo-common/src/main/kotlin/org/jitsi/jicofo/xmpp/jingle/JingleSession.kt +++ b/jicofo-common/src/main/kotlin/org/jitsi/jicofo/xmpp/jingle/JingleSession.kt @@ -36,6 +36,7 @@ import org.jitsi.xmpp.extensions.jingle.JinglePacketFactory import org.jitsi.xmpp.extensions.jingle.Reason import org.jitsi.xmpp.extensions.jingle.RtpDescriptionPacketExtension import org.jitsi.xmpp.extensions.jitsimeet.JsonMessageExtension +import org.jitsi.xmpp.util.XmlStringBuilderUtil.Companion.toStringOpt import org.jivesoftware.smack.AbstractXMPPConnection import org.jivesoftware.smack.SmackException import org.jivesoftware.smack.packet.ExtensionElement @@ -143,7 +144,7 @@ class JingleSession( val response = if (error == null) { IQ.createResultIQ(iq) } else { - logger.info("Returning error: request=${iq.toXML()}, error=${error.toXML()} ") + logger.info("Returning error: request=${iq.toStringOpt()}, error=${error.toStringOpt()} ") IQ.createErrorResponse(iq, error) } connection.tryToSendStanza(response) @@ -207,7 +208,7 @@ class JingleSession( return if (response?.type == IQ.Type.result) { true } else { - logger.error("Unexpected response to transport-replace: ${response?.toXML()}") + logger.error("Unexpected response to transport-replace: ${response?.toStringOpt()}") false } } diff --git a/jicofo-common/src/main/kotlin/org/jitsi/jicofo/xmpp/muc/ChatRoomImpl.kt b/jicofo-common/src/main/kotlin/org/jitsi/jicofo/xmpp/muc/ChatRoomImpl.kt index bbce50a15f..dfe189a7f3 100644 --- a/jicofo-common/src/main/kotlin/org/jitsi/jicofo/xmpp/muc/ChatRoomImpl.kt +++ b/jicofo-common/src/main/kotlin/org/jitsi/jicofo/xmpp/muc/ChatRoomImpl.kt @@ -31,6 +31,7 @@ import org.jitsi.utils.event.EventEmitter import org.jitsi.utils.event.SyncEventEmitter import org.jitsi.utils.logging2.createLogger import org.jitsi.utils.observableWhenChanged +import org.jitsi.xmpp.util.XmlStringBuilderUtil.Companion.toStringOpt import org.jivesoftware.smack.PresenceListener import org.jivesoftware.smack.SmackException import org.jivesoftware.smack.XMPPConnection @@ -309,7 +310,7 @@ class ChatRoomImpl( try { val reply = xmppProvider.xmppConnection.sendIqAndGetResponse(admin) if (reply == null || reply.type != IQ.Type.result) { - logger.warn("Failed to grant ownership: ${reply?.toXML() ?: "timeout"}") + logger.warn("Failed to grant ownership: ${reply?.toString() ?: "timeout"}") } } catch (e: SmackException.NotConnectedException) { logger.warn("Failed to grant ownership: XMPP disconnected") @@ -505,15 +506,15 @@ class ChatRoomImpl( */ override fun processPresence(presence: Presence?) { if (presence == null || presence.error != null) { - logger.warn("Unable to handle packet: ${presence?.toXML()}") + logger.warn("Unable to handle packet: ${presence?.toXML()?.toStringOpt()}") return } - logger.trace { "Presence received ${presence.toXML()}" } + logger.trace { "Presence received ${presence.toXML().toStringOpt()}" } // Should never happen, but log if something is broken val myOccupantJid = this.myOccupantJid if (myOccupantJid == null) { - logger.error("Processing presence when myOccupantJid is not set: ${presence.toXML()}") + logger.error("Processing presence when myOccupantJid is not set: ${presence.toXML().toStringOpt()}") } if (myOccupantJid != null && myOccupantJid.equals(presence.from)) { processOwnPresence(presence) diff --git a/jicofo-selector/src/main/java/org/jitsi/jicofo/bridge/JvbDoctor.java b/jicofo-selector/src/main/java/org/jitsi/jicofo/bridge/JvbDoctor.java index 037a268485..80bbffc972 100644 --- a/jicofo-selector/src/main/java/org/jitsi/jicofo/bridge/JvbDoctor.java +++ b/jicofo-selector/src/main/java/org/jitsi/jicofo/bridge/JvbDoctor.java @@ -23,6 +23,7 @@ import org.jitsi.utils.logging2.*; import org.jitsi.xmpp.extensions.health.*; +import org.jitsi.xmpp.util.*; import org.jivesoftware.smack.*; import org.jivesoftware.smack.packet.*; @@ -236,13 +237,16 @@ protected void doHealthCheck() || StanzaError.Condition.service_unavailable.equals(condition)) { // Health check failure - logger.warn("Health check failed for: " + bridge + ": " + error.toXML().toString()); + logger.warn( + "Health check failed for: " + bridge + ": " + XmlStringBuilderUtil.toStringOpt(error) + ); listener.healthCheckFailed(bridge.getJid()); } else { logger.error( - "Unexpected error returned by the bridge: " + bridge + ", err: " + response.toXML()); + "Unexpected error returned by the bridge: " + bridge + ", err: " + + XmlStringBuilderUtil.toStringOpt(response)); } } } diff --git a/jicofo-selector/src/main/kotlin/org/jitsi/jicofo/bridge/colibri/Colibri2Session.kt b/jicofo-selector/src/main/kotlin/org/jitsi/jicofo/bridge/colibri/Colibri2Session.kt index 9c96d582db..3633b4e0d0 100644 --- a/jicofo-selector/src/main/kotlin/org/jitsi/jicofo/bridge/colibri/Colibri2Session.kt +++ b/jicofo-selector/src/main/kotlin/org/jitsi/jicofo/bridge/colibri/Colibri2Session.kt @@ -43,6 +43,7 @@ import org.jitsi.xmpp.extensions.colibri2.Transport import org.jitsi.xmpp.extensions.jingle.DtlsFingerprintPacketExtension import org.jitsi.xmpp.extensions.jingle.ExtmapAllowMixedPacketExtension import org.jitsi.xmpp.extensions.jingle.IceUdpTransportPacketExtension +import org.jitsi.xmpp.util.XmlStringBuilderUtil.Companion.toStringOpt import org.jivesoftware.smack.StanzaCollector import org.jivesoftware.smack.packet.ErrorIQ import org.jivesoftware.smack.packet.IQ @@ -110,7 +111,7 @@ class Colibri2Session( participant.medias.forEach { endpoint.addMedia(it) } request.addEndpoint(endpoint.build()) - logger.trace { "Sending allocation request for ${participant.id}: ${request.build().toXML()}" } + logger.trace { "Sending allocation request for ${participant.id}: ${request.build().toStringOpt()}" } created = true return xmppConnection.createStanzaCollectorAndSend(request.build()) } @@ -259,7 +260,7 @@ class Colibri2Session( relayId: String ) { logger.info("Setting relay transport for $relayId") - logger.debug { "Setting relay transport for $relayId: ${transport.toXML()}" } + logger.debug { "Setting relay transport for $relayId: ${transport.toStringOpt()}" } relays[relayId]?.setTransport(transport) ?: throw IllegalStateException("Relay $relayId doesn't exist (bridge=${this.relayId}") } @@ -292,10 +293,10 @@ class Colibri2Session( * failure. */ private fun sendRequest(iq: IQ, name: String) { - logger.debug { "Sending $name request: ${iq.toXML()}" } + logger.debug { "Sending $name request: ${iq.toStringOpt()}" } xmppConnection.sendIqAndHandleResponseAsync(iq) { when (it) { - is ConferenceModifiedIQ -> logger.debug { "Received $name response: ${it.toXML()}" } + is ConferenceModifiedIQ -> logger.debug { "Received $name response: ${it.toStringOpt()}" } null -> logger.info("$name request timed out. Ignoring.") else -> { if (it is ErrorIQ) { @@ -313,14 +314,14 @@ class Colibri2Session( val reInvite = reason == Colibri2Error.Reason.UNKNOWN_ENDPOINT && endpointId != null if (reInvite) { logger.warn( - "Endpoint [$endpointId] is not found, session failed: ${it.toXML()}, " + - "request was: ${iq.toXML()}" + "Endpoint [$endpointId] is not found, session failed: ${it.toStringOpt()}, " + + "request was: ${iq.toStringOpt()}" ) colibriSessionManager.endpointFailed(endpointId!!) return@sendIqAndHandleResponseAsync } } - logger.error("Received error response for $name, session failed: ${it.toXML()}") + logger.error("Received error response for $name, session failed: ${it.toStringOpt()}") colibriSessionManager.sessionFailed(this@Colibri2Session) } } @@ -367,14 +368,14 @@ class Colibri2Session( /** Send a request to allocate a new relay, and submit a task to wait for a response. */ internal fun start(initialParticipants: List) { val request = buildCreateRelayRequest(initialParticipants) - logger.trace { "Sending create relay: ${request.toXML()}" } + logger.trace { "Sending create relay: ${request.toStringOpt()}" } xmppConnection.sendIqAndHandleResponseAsync(request) { response -> // Wait for a response to the relay allocation request. When a response is received, parse the contained // transport and forward it to the associated [Relay] for the remote side via [colibriSessionManager] - logger.trace { "Received response: ${response?.toXML()}" } + logger.trace { "Received response: ${response?.toStringOpt()}" } if (response !is ConferenceModifiedIQ) { - logger.error("Received error: ${response?.toXML() ?: "timeout"}") + logger.error("Received error: ${response?.toStringOpt() ?: "timeout"}") colibriSessionManager.sessionFailed(this@Colibri2Session) return@sendIqAndHandleResponseAsync } @@ -382,7 +383,7 @@ class Colibri2Session( // TODO: We just assume that the response has a single [Colibri2Relay]. val transport = response.relays.firstOrNull()?.transport ?: run { - logger.error("No transport in response: ${response.toXML()}") + logger.error("No transport in response: ${response.toStringOpt()}") colibriSessionManager.sessionFailed(this@Colibri2Session) return@sendIqAndHandleResponseAsync } diff --git a/jicofo-selector/src/main/kotlin/org/jitsi/jicofo/bridge/colibri/ColibriV2SessionManager.kt b/jicofo-selector/src/main/kotlin/org/jitsi/jicofo/bridge/colibri/ColibriV2SessionManager.kt index c25a2005cc..d15b331428 100644 --- a/jicofo-selector/src/main/kotlin/org/jitsi/jicofo/bridge/colibri/ColibriV2SessionManager.kt +++ b/jicofo-selector/src/main/kotlin/org/jitsi/jicofo/bridge/colibri/ColibriV2SessionManager.kt @@ -42,6 +42,7 @@ import org.jitsi.xmpp.extensions.colibri2.Colibri2Error import org.jitsi.xmpp.extensions.colibri2.ConferenceModifiedIQ import org.jitsi.xmpp.extensions.colibri2.InitialLastN import org.jitsi.xmpp.extensions.jingle.IceUdpTransportPacketExtension +import org.jitsi.xmpp.util.XmlStringBuilderUtil.Companion.toStringOpt import org.jivesoftware.smack.AbstractXMPPConnection import org.jivesoftware.smack.StanzaCollector import org.jivesoftware.smack.packet.ErrorIQ @@ -359,7 +360,7 @@ class ColibriV2SessionManager( val response: IQ? try { response = stanzaCollector.nextResult() - logger.trace { "Received response: ${response?.toXML()}" } + logger.trace { "Received response: ${response?.toStringOpt()}" } } finally { stanzaCollector.cancel() } @@ -435,13 +436,13 @@ class ColibriV2SessionManager( Colibri2Error.ELEMENT, Colibri2Error.NAMESPACE )?.reason - logger.info("Received error response: ${response.toXML()}") + logger.info("Received error response: ${response.toStringOpt()}") when (response.error?.condition) { bad_request -> { // Most probably we sent a bad request. // If we flag the bridge as non-operational we may disrupt other conferences. // If we trigger a re-invite we may cause the same error repeating. - throw ColibriAllocationFailedException("Bad request: ${response.error?.toXML()?.toString()}", false) + throw ColibriAllocationFailedException("Bad request: ${response.error?.toStringOpt()}", false) } item_not_found -> { if (reason == Colibri2Error.Reason.CONFERENCE_NOT_FOUND) { @@ -460,7 +461,7 @@ class ColibriV2SessionManager( if (reason == null) { // An error NOT coming from the bridge. throw ColibriAllocationFailedException( - "XMPP error: ${response.error?.toXML()}", + "XMPP error: ${response.error?.toStringOpt()}", true ) } else if (reason == Colibri2Error.Reason.CONFERENCE_ALREADY_EXISTS) { @@ -473,7 +474,7 @@ class ColibriV2SessionManager( // we can't expire a conference without listing its individual endpoints and we think there // were none. // We remove the bridge from the conference (expiring it) and re-invite the participants. - throw ColibriAllocationFailedException("Colibri error: ${response.error?.toXML()}", true) + throw ColibriAllocationFailedException("Colibri error: ${response.error?.toStringOpt()}", true) } } service_unavailable -> { @@ -489,7 +490,7 @@ class ColibriV2SessionManager( } else -> { session.bridge.isOperational = false - throw ColibriAllocationFailedException("Error: ${response.error?.toXML()}", true) + throw ColibriAllocationFailedException("Error: ${response.error?.toStringOpt()}", true) } } } @@ -618,7 +619,7 @@ class ColibriV2SessionManager( relayId: String ) { logger.info("Received transport from $session for relay $relayId") - logger.debug { "Received transport from $session for relay $relayId: ${transport.toXML()}" } + logger.debug { "Received transport from $session for relay $relayId: ${transport.toStringOpt()}" } synchronized(syncRoot) { // It's possible a new session was started for the same bridge. if (!sessions.containsKey(session.bridge.relayId) || sessions[session.bridge.relayId] != session) { diff --git a/jicofo/src/main/java/org/jitsi/jicofo/conference/ParticipantInviteRunnable.java b/jicofo/src/main/java/org/jitsi/jicofo/conference/ParticipantInviteRunnable.java index 189409b694..f19cca556b 100644 --- a/jicofo/src/main/java/org/jitsi/jicofo/conference/ParticipantInviteRunnable.java +++ b/jicofo/src/main/java/org/jitsi/jicofo/conference/ParticipantInviteRunnable.java @@ -33,6 +33,7 @@ import org.jitsi.xmpp.extensions.jingle.JingleUtils; import org.jitsi.xmpp.extensions.jitsimeet.*; import org.jitsi.utils.logging2.*; +import org.jitsi.xmpp.util.*; import org.jivesoftware.smack.*; import org.jivesoftware.smack.packet.*; import org.jxmpp.jid.*; @@ -187,7 +188,9 @@ private void doRun() } else { - logger.warn("Failed to convert ContentPacketExtension to Media: " + content.toXML()); + logger.warn( + "Failed to convert ContentPacketExtension to Media: " + + XmlStringBuilderUtil.toStringOpt(content)); } }); // This makes the bridge signal its private host candidates. We enable them for backend components, because diff --git a/jicofo/src/main/java/org/jitsi/jicofo/jibri/JibriSession.java b/jicofo/src/main/java/org/jitsi/jicofo/jibri/JibriSession.java index 36eec109d3..855024d6fb 100644 --- a/jicofo/src/main/java/org/jitsi/jicofo/jibri/JibriSession.java +++ b/jicofo/src/main/java/org/jitsi/jicofo/jibri/JibriSession.java @@ -25,6 +25,7 @@ import org.jitsi.xmpp.extensions.jibri.JibriIq.*; import org.jetbrains.annotations.*; import org.jitsi.utils.logging2.*; +import org.jitsi.xmpp.util.*; import org.jivesoftware.smack.*; import org.jivesoftware.smack.packet.*; import org.jxmpp.jid.*; @@ -351,7 +352,7 @@ synchronized public void stop(Jid initiator) stopRequest.setAction(JibriIq.Action.STOP); stopRequest.setSessionId(this.sessionId); - logger.info("Trying to stop: " + stopRequest.toXML()); + logger.info("Trying to stop: " + XmlStringBuilderUtil.toStringOpt(stopRequest)); SmackFuture future = jibriDetector.getXmppConnection().sendIqRequestAsync(stopRequest, 60000); @@ -366,7 +367,7 @@ synchronized public void stop(Jid initiator) { logger.error( "Unexpected response to stop iq: " - + (stanza != null ? stanza.toXML() : "null")); + + (stanza != null ? XmlStringBuilderUtil.toStringOpt(stanza) : "null")); JibriIq error = new JibriIq(); @@ -428,7 +429,7 @@ private void processJibriIqFromJibri(JibriIq iq) JibriIq.Status status = iq.getStatus(); if (!JibriIq.Status.UNDEFINED.equals(status)) { - logger.info("Updating status from JIBRI: " + iq.toXML() + " for " + roomName); + logger.info("Updating status from JIBRI: " + XmlStringBuilderUtil.toStringOpt(iq) + " for " + roomName); handleJibriStatusUpdate(iq.getFrom(), status, iq.getFailureReason(), iq.getShouldRetry()); } @@ -535,7 +536,7 @@ private void sendJibriStartIq(final Jid jibriJid) } if (!(reply instanceof JibriIq)) { - logger.error("Unexpected response to start request: " + reply.toXML()); + logger.error("Unexpected response to start request: " + XmlStringBuilderUtil.toStringOpt(reply)); throw new StartException.UnexpectedResponse(); } @@ -549,8 +550,7 @@ private void sendJibriStartIq(final Jid jibriJid) if (!isPendingResponse(jibriIq)) { logger.error( - "Unexpected status received in response to the start IQ: " - + jibriIq.toXML()); + "Unexpected status received in response to the start IQ: " + XmlStringBuilderUtil.toStringOpt(jibriIq)); throw new StartException.UnexpectedResponse(); } diff --git a/jicofo/src/main/kotlin/org/jitsi/jicofo/conference/Participant.kt b/jicofo/src/main/kotlin/org/jitsi/jicofo/conference/Participant.kt index f6e9afeeaf..11fccc7d4d 100644 --- a/jicofo/src/main/kotlin/org/jitsi/jicofo/conference/Participant.kt +++ b/jicofo/src/main/kotlin/org/jitsi/jicofo/conference/Participant.kt @@ -46,6 +46,7 @@ import org.jitsi.xmpp.extensions.jingle.JingleIQ import org.jitsi.xmpp.extensions.jingle.Reason import org.jitsi.xmpp.extensions.jitsimeet.BridgeSessionPacketExtension import org.jitsi.xmpp.extensions.jitsimeet.IceStatePacketExtension +import org.jitsi.xmpp.util.XmlStringBuilderUtil.Companion.toStringOpt import org.jivesoftware.smack.packet.StanzaError import org.jxmpp.jid.EntityFullJid import java.time.Clock @@ -564,7 +565,7 @@ open class Participant @JvmOverloads constructor( override fun onTransportReject(jingleSession: JingleSession, iq: JingleIQ) { checkJingleSession(jingleSession)?.let { return } - logger.warn("Received transport-reject: ${iq.toXML()}") + logger.warn("Received transport-reject: ${iq.toStringOpt()}") } } } diff --git a/jicofo/src/main/kotlin/org/jitsi/jicofo/jibri/BaseJibri.kt b/jicofo/src/main/kotlin/org/jitsi/jicofo/jibri/BaseJibri.kt index 75cdb06ee9..5f16d75f35 100644 --- a/jicofo/src/main/kotlin/org/jitsi/jicofo/jibri/BaseJibri.kt +++ b/jicofo/src/main/kotlin/org/jitsi/jicofo/jibri/BaseJibri.kt @@ -30,6 +30,7 @@ import org.jitsi.utils.logging2.Logger import org.jitsi.utils.queue.PacketQueue import org.jitsi.xmpp.extensions.jibri.JibriIq import org.jitsi.xmpp.extensions.jibri.JibriIq.Action +import org.jitsi.xmpp.util.XmlStringBuilderUtil.Companion.toStringOpt import org.jivesoftware.smack.packet.IQ import org.jivesoftware.smack.packet.StanzaError import java.lang.Exception @@ -71,7 +72,7 @@ abstract class BaseJibri internal constructor( protected val logger: Logger = parentLogger.createChildLogger(BaseJibri::class.simpleName) fun handleJibriRequest(request: JibriRequest): IqProcessingResult = if (accept(request.iq)) { - logger.info("Accepted jibri request: ${request.iq.toXML()}") + logger.info("Accepted jibri request: ${request.iq.toStringOpt()}") incomingIqQueue.add(request) AcceptedWithNoResponse() } else { @@ -147,7 +148,7 @@ abstract class BaseJibri internal constructor( * @return the IQ to be sent back as a response ('result' or 'error'). */ private fun doHandleIQRequest(iq: JibriIq): IQ { - logger.debug { "Jibri request. IQ: ${iq.toXML()}" } + logger.debug { "Jibri request. IQ: ${iq.toStringOpt()}" } // Coming from a Jibri instance. val session = getJibriSessionForMeetIq(iq) @@ -174,7 +175,7 @@ abstract class BaseJibri internal constructor( } Action.STOP -> when (session) { null -> { - logger.warn("Rejecting STOP request for an unknown session.: ${iq.toXML()}") + logger.warn("Rejecting STOP request for an unknown session.: ${iq.toStringOpt()}") error(iq, StanzaError.Condition.item_not_found, "Unknown session") } else -> { @@ -183,7 +184,7 @@ abstract class BaseJibri internal constructor( } } Action.UNDEFINED, null -> { - return error(iq, StanzaError.Condition.bad_request, "undefined action ${iq.toXML()}") + return error(iq, StanzaError.Condition.bad_request, "undefined action ${iq.toStringOpt()}") } } } diff --git a/jicofo/src/main/kotlin/org/jitsi/jicofo/jibri/JibriRecorder.kt b/jicofo/src/main/kotlin/org/jitsi/jicofo/jibri/JibriRecorder.kt index 95807f79a2..81f54ff58f 100644 --- a/jicofo/src/main/kotlin/org/jitsi/jicofo/jibri/JibriRecorder.kt +++ b/jicofo/src/main/kotlin/org/jitsi/jicofo/jibri/JibriRecorder.kt @@ -29,6 +29,7 @@ import org.jitsi.xmpp.extensions.jibri.JibriIq import org.jitsi.xmpp.extensions.jibri.JibriIq.RecordingMode import org.jitsi.xmpp.extensions.jibri.JibriIq.Status import org.jitsi.xmpp.extensions.jibri.RecordingStatus +import org.jitsi.xmpp.util.XmlStringBuilderUtil.Companion.toStringOpt import org.jivesoftware.smack.packet.IQ import org.jivesoftware.smack.packet.StanzaError import org.jitsi.jicofo.util.ErrorResponse.create as error @@ -183,7 +184,9 @@ class JibriRecorder( } } } - logger.info("Publishing new jibri-recording-status: ${recordingStatus.toXML()} in: " + conference.roomName) + logger.info( + "Publishing new jibri-recording-status: ${recordingStatus.toStringOpt()} in: ${conference.roomName}" + ) conference.chatRoom?.setPresenceExtension(recordingStatus) } diff --git a/jicofo/src/main/kotlin/org/jitsi/jicofo/jibri/JibriSipGateway.kt b/jicofo/src/main/kotlin/org/jitsi/jicofo/jibri/JibriSipGateway.kt index e33315818d..b013294919 100644 --- a/jicofo/src/main/kotlin/org/jitsi/jicofo/jibri/JibriSipGateway.kt +++ b/jicofo/src/main/kotlin/org/jitsi/jicofo/jibri/JibriSipGateway.kt @@ -26,6 +26,7 @@ import org.jitsi.jicofo.jibri.JibriSession.StartException.NotAvailable import org.jitsi.utils.logging2.Logger import org.jitsi.xmpp.extensions.jibri.JibriIq import org.jitsi.xmpp.extensions.jibri.SipCallState +import org.jitsi.xmpp.util.XmlStringBuilderUtil.Companion.toStringOpt import org.jivesoftware.smack.packet.IQ import org.jivesoftware.smack.packet.StanzaError import kotlin.collections.HashMap @@ -139,7 +140,7 @@ class JibriSipGateway( sipAddress = session.sipAddress sessionId = session.sessionId } - logger.info("Publishing new state: ${session.sipAddress} ${sipCallState.toXML()}") + logger.info("Publishing new state: ${session.sipAddress} ${sipCallState.toStringOpt()}") // Publish that in the presence conference.chatRoom?.setPresenceExtension(sipCallState) ?: logger.warn("chatRoom is null") diff --git a/jicofo/src/main/kotlin/org/jitsi/jicofo/rest/ConferenceRequest.kt b/jicofo/src/main/kotlin/org/jitsi/jicofo/rest/ConferenceRequest.kt index c64a318ea4..3c56c08b78 100644 --- a/jicofo/src/main/kotlin/org/jitsi/jicofo/rest/ConferenceRequest.kt +++ b/jicofo/src/main/kotlin/org/jitsi/jicofo/rest/ConferenceRequest.kt @@ -59,11 +59,9 @@ class ConferenceRequest( if (response is ErrorIQ) { throw when (response.error.condition) { StanzaError.Condition.not_authorized -> { - System.err.println("Not authorised") ForbiddenException() } StanzaError.Condition.not_acceptable -> { - System.err.println("not_acceptable") BadRequestExceptionWithMessage("invalid-session") } else -> BadRequestExceptionWithMessage(response.error.toString()) diff --git a/jicofo/src/main/kotlin/org/jitsi/jicofo/xmpp/AuthenticationIqHandler.kt b/jicofo/src/main/kotlin/org/jitsi/jicofo/xmpp/AuthenticationIqHandler.kt index 94889173be..9de87657c8 100644 --- a/jicofo/src/main/kotlin/org/jitsi/jicofo/xmpp/AuthenticationIqHandler.kt +++ b/jicofo/src/main/kotlin/org/jitsi/jicofo/xmpp/AuthenticationIqHandler.kt @@ -22,6 +22,7 @@ import org.jitsi.jicofo.auth.AuthenticationAuthority import org.jitsi.utils.logging2.createLogger import org.jitsi.xmpp.extensions.jitsimeet.LoginUrlIq import org.jitsi.xmpp.extensions.jitsimeet.LogoutIq +import org.jitsi.xmpp.util.XmlStringBuilderUtil.Companion.toStringOpt import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler import org.jivesoftware.smack.iqrequest.IQRequestHandler import org.jivesoftware.smack.packet.IQ @@ -46,7 +47,7 @@ class AuthenticationIqHandler(private val authAuthority: AuthenticationAuthority stanzaId = loginUrlIq.stanzaId to = loginUrlIq.from url = authAuthority.createLoginUrl(machineUID, peerFullJid, roomName, popup) - logger.info("Sending url: ${toXML()}") + logger.info("Sending url: ${toStringOpt()}") } } diff --git a/jicofo/src/main/kotlin/org/jitsi/jicofo/xmpp/JibriIqHandler.kt b/jicofo/src/main/kotlin/org/jitsi/jicofo/xmpp/JibriIqHandler.kt index 68bb9ddce4..ff2891ac5d 100644 --- a/jicofo/src/main/kotlin/org/jitsi/jicofo/xmpp/JibriIqHandler.kt +++ b/jicofo/src/main/kotlin/org/jitsi/jicofo/xmpp/JibriIqHandler.kt @@ -25,6 +25,7 @@ import org.jitsi.jicofo.xmpp.IqProcessingResult.AcceptedWithResponse import org.jitsi.jicofo.xmpp.IqProcessingResult.RejectedWithError import org.jitsi.utils.logging2.createLogger import org.jitsi.xmpp.extensions.jibri.JibriIq +import org.jitsi.xmpp.util.XmlStringBuilderUtil.Companion.toStringOpt import org.jivesoftware.smack.AbstractXMPPConnection import org.jivesoftware.smack.iqrequest.IQRequestHandler import org.jivesoftware.smack.packet.IQ @@ -64,7 +65,7 @@ class JibriIqHandler( } // No conference accepted the request. - logger.warn("Jibri IQ not accepted by any conference: ${request.iq.toXML()}") + logger.warn("Jibri IQ not accepted by any conference: ${request.iq.toStringOpt()}") if (JicofoServices.jicofoServicesSingleton?.jibriDetector == null && JicofoServices.jicofoServicesSingleton?.sipJibriDetector == null ) { diff --git a/jicofo/src/main/kotlin/org/jitsi/jicofo/xmpp/JigasiIqHandler.kt b/jicofo/src/main/kotlin/org/jitsi/jicofo/xmpp/JigasiIqHandler.kt index c03ba49048..283d478cae 100644 --- a/jicofo/src/main/kotlin/org/jitsi/jicofo/xmpp/JigasiIqHandler.kt +++ b/jicofo/src/main/kotlin/org/jitsi/jicofo/xmpp/JigasiIqHandler.kt @@ -26,6 +26,7 @@ import org.jitsi.jicofo.xmpp.IqProcessingResult.RejectedWithError import org.jitsi.utils.OrderedJsonObject import org.jitsi.utils.logging2.createLogger import org.jitsi.xmpp.extensions.rayo.DialIq +import org.jitsi.xmpp.util.XmlStringBuilderUtil.Companion.toStringOpt import org.jivesoftware.smack.AbstractXMPPConnection import org.jivesoftware.smack.SmackException import org.jivesoftware.smack.packet.ErrorIQ @@ -73,7 +74,7 @@ class JigasiIqHandler( } } - logger.info("Accepted jigasi request from ${request.iq.from}: ${request.iq.toXML()}") + logger.info("Accepted jigasi request from ${request.iq.from}: ${request.iq.toStringOpt()}") Stats.acceptedRequests.inc() TaskPools.ioPool.execute { @@ -101,7 +102,7 @@ class JigasiIqHandler( ) { // Check if Jigasi is available val jigasiJid = jigasiDetector.selectSipJigasi(exclude, conferenceRegions) ?: run { - logger.warn("Request failed, no instances available: ${request.iq.toXML()}") + logger.warn("Request failed, no instances available: ${request.iq.toStringOpt()}") request.connection.tryToSendStanza( IQ.createErrorResponse( request.iq, @@ -122,7 +123,7 @@ class JigasiIqHandler( val responseFromJigasi = try { jigasiDetector.xmppConnection.sendIqAndGetResponse(requestToJigasi) } catch (e: SmackException.NotConnectedException) { - logger.error("Request failed, XMPP not connected: ${request.iq.toXML()}") + logger.error("Request failed, XMPP not connected: ${request.iq.toStringOpt()}") stats.xmppNotConnected() return } @@ -133,7 +134,7 @@ class JigasiIqHandler( logger.warn("Jigasi instance timed out: $jigasiJid") Stats.singleInstanceTimeouts.inc() } else { - logger.warn("Jigasi instance returned error ($jigasiJid): ${responseFromJigasi.toXML()}") + logger.warn("Jigasi instance returned error ($jigasiJid): ${responseFromJigasi.toStringOpt()}") Stats.singleInstanceErrors.inc() } diff --git a/jicofo/src/main/kotlin/org/jitsi/jicofo/xmpp/MuteIqHandler.kt b/jicofo/src/main/kotlin/org/jitsi/jicofo/xmpp/MuteIqHandler.kt index fd182535bb..f28c60dce4 100644 --- a/jicofo/src/main/kotlin/org/jitsi/jicofo/xmpp/MuteIqHandler.kt +++ b/jicofo/src/main/kotlin/org/jitsi/jicofo/xmpp/MuteIqHandler.kt @@ -26,6 +26,7 @@ import org.jitsi.utils.MediaType import org.jitsi.utils.logging2.LoggerImpl import org.jitsi.xmpp.extensions.jitsimeet.MuteIq import org.jitsi.xmpp.extensions.jitsimeet.MuteVideoIq +import org.jitsi.xmpp.util.XmlStringBuilderUtil.Companion.toStringOpt import org.jivesoftware.smack.AbstractXMPPConnection import org.jivesoftware.smack.iqrequest.IQRequestHandler import org.jivesoftware.smack.packet.IQ @@ -89,13 +90,13 @@ private fun handleRequest(request: MuteRequest): IqProcessingResult { val doMute = request.doMute val mediaType = request.mediaType if (doMute == null || jidToMute == null) { - logger.warn("Mute request missing required fields: ${request.iq.toXML()}") + logger.warn("Mute request missing required fields: ${request.iq.toStringOpt()}") return RejectedWithError(request.iq, StanzaError.Condition.bad_request) } val conference = request.conferenceStore.getConference(request.iq.from.asEntityBareJidIfPossible()) ?: return RejectedWithError(request.iq, StanzaError.Condition.item_not_found).also { - logger.warn("Mute request for unknown conference: ${request.iq.toXML()}") + logger.warn("Mute request for unknown conference: ${request.iq.toStringOpt()}") } TaskPools.ioPool.execute { @@ -138,7 +139,7 @@ private fun handleRequest(request: MuteRequest): IqProcessingResult { ) } } catch (e: Exception) { - logger.warn("Failed to handle mute request: ${request.iq.toXML()}", e) + logger.warn("Failed to handle mute request: ${request.iq.toStringOpt()}", e) request.connection.tryToSendStanza( IQ.createErrorResponse(request.iq, StanzaError.Condition.internal_server_error) ) diff --git a/jicofo/src/main/kotlin/org/jitsi/jicofo/xmpp/VisitorsManager.kt b/jicofo/src/main/kotlin/org/jitsi/jicofo/xmpp/VisitorsManager.kt index 30650f4e00..d63e342176 100644 --- a/jicofo/src/main/kotlin/org/jitsi/jicofo/xmpp/VisitorsManager.kt +++ b/jicofo/src/main/kotlin/org/jitsi/jicofo/xmpp/VisitorsManager.kt @@ -22,6 +22,7 @@ import org.jitsi.jicofo.TaskPools import org.jitsi.jicofo.visitors.VisitorsConfig import org.jitsi.utils.logging2.createLogger import org.jitsi.xmpp.extensions.visitors.VisitorsIq +import org.jitsi.xmpp.util.XmlStringBuilderUtil.Companion.toStringOpt import org.jivesoftware.smack.StanzaListener import org.jivesoftware.smack.filter.StanzaFilter import org.jivesoftware.smack.packet.ExtensionElement @@ -69,8 +70,10 @@ class VisitorsManager( val response = xmppProvider.xmppConnection.sendIqAndGetResponse(iq) when { response == null -> logger.warn("Timeout waiting for VisitorsIq response.") - response.type == IQ.Type.result -> logger.info("Received VisitorsIq response: ${response.toXML()}") - else -> logger.warn("Received error response: ${response.toXML()}") + response.type == IQ.Type.result -> { + logger.info("Received VisitorsIq response: ${response.toStringOpt()}") + } + else -> logger.warn("Received error response: ${response.toStringOpt()}") } } } @@ -98,7 +101,7 @@ class VisitorsManager( logger.warn("Ignoring VisitorsIq for unknown conference ${stanza.room}.") return } - logger.info("Received VisitorsIq: ${stanza.toXML()}") + logger.info("Received VisitorsIq: ${stanza.toStringOpt()}") // TODO pass to the conference } } diff --git a/jicofo/src/test/kotlin/org/jitsi/jicofo/auth/XMPPDomainAuthAuthorityTest.kt b/jicofo/src/test/kotlin/org/jitsi/jicofo/auth/XMPPDomainAuthAuthorityTest.kt index 18b43203fe..c965501d75 100644 --- a/jicofo/src/test/kotlin/org/jitsi/jicofo/auth/XMPPDomainAuthAuthorityTest.kt +++ b/jicofo/src/test/kotlin/org/jitsi/jicofo/auth/XMPPDomainAuthAuthorityTest.kt @@ -10,6 +10,7 @@ import org.jitsi.jicofo.auth.XMPPDomainAuthAuthority import org.jitsi.jicofo.xmpp.ConferenceIqHandler import org.jitsi.xmpp.extensions.jitsimeet.ConferenceIq import org.jitsi.xmpp.extensions.jitsimeet.SessionInvalidPacketExtension +import org.jitsi.xmpp.util.XmlStringBuilderUtil.Companion.toStringOpt import org.jivesoftware.smack.packet.IQ import org.jivesoftware.smack.packet.StanzaError.Condition import org.jxmpp.jid.impl.JidCreate @@ -94,9 +95,8 @@ class XMPPDomainAuthAuthorityTest : ShouldSpec() { machineUID = user2MachineUid } - println("query=${query.toXML()}") + println("query=${query.toStringOpt()}") conferenceIqHandler.handleConferenceIq(query).let { - println("XXX ${it.toXML()}") it.shouldBeInstanceOf() it.sessionId shouldBe null } diff --git a/jicofo/src/test/kotlin/org/jitsi/jicofo/conference/ConferenceTest.kt b/jicofo/src/test/kotlin/org/jitsi/jicofo/conference/ConferenceTest.kt index 591ab12681..158d7f037d 100644 --- a/jicofo/src/test/kotlin/org/jitsi/jicofo/conference/ConferenceTest.kt +++ b/jicofo/src/test/kotlin/org/jitsi/jicofo/conference/ConferenceTest.kt @@ -47,6 +47,7 @@ import org.jitsi.xmpp.extensions.jingle.IceUdpTransportPacketExtension import org.jitsi.xmpp.extensions.jingle.JingleAction import org.jitsi.xmpp.extensions.jingle.JingleIQ import org.jitsi.xmpp.extensions.jingle.RtpDescriptionPacketExtension +import org.jitsi.xmpp.util.XmlStringBuilderUtil.Companion.toStringOpt import org.jivesoftware.smack.packet.IQ import org.jxmpp.jid.Jid import org.jxmpp.jid.impl.JidCreate @@ -401,7 +402,7 @@ class ColibriAndJingleXmppConnection : MockXmppConnection() { is ConferenceModifyIQ -> colibri2Server.handleConferenceModifyIq(iq) is JingleIQ -> remoteParticipants.computeIfAbsent(iq.to) { RemoteParticipant(iq.to) }.handleJingleIq(iq) else -> { - println("Not handling ${iq.toXML()}") + println("Not handling ${iq.toStringOpt()}") null } }.also { diff --git a/jicofo/src/test/kotlin/org/jitsi/jicofo/xmpp/jigasi/JigasiIqHandlerTest.kt b/jicofo/src/test/kotlin/org/jitsi/jicofo/xmpp/jigasi/JigasiIqHandlerTest.kt index 3ea88ed9b9..bf3da5eaf7 100644 --- a/jicofo/src/test/kotlin/org/jitsi/jicofo/xmpp/jigasi/JigasiIqHandlerTest.kt +++ b/jicofo/src/test/kotlin/org/jitsi/jicofo/xmpp/jigasi/JigasiIqHandlerTest.kt @@ -35,6 +35,7 @@ import org.jitsi.jicofo.xmpp.IqProcessingResult.RejectedWithError import org.jitsi.jicofo.xmpp.IqRequest import org.jitsi.jicofo.xmpp.JigasiIqHandler import org.jitsi.xmpp.extensions.rayo.DialIq +import org.jitsi.xmpp.util.XmlStringBuilderUtil.Companion.toStringOpt import org.jivesoftware.smack.packet.EmptyResultIQ import org.jivesoftware.smack.packet.ErrorIQ import org.jivesoftware.smack.packet.IQ @@ -184,7 +185,7 @@ class JigasiXmppConnection : MockXmppConnection() { } } else -> { - println("Not handling ${iq.toXML()}") + println("Not handling ${iq.toStringOpt()}") null } } diff --git a/pom.xml b/pom.xml index fee0da2962..ec8ba20b64 100644 --- a/pom.xml +++ b/pom.xml @@ -178,7 +178,7 @@ ${project.groupId} jitsi-xmpp-extensions - 1.0-76-ge98f8af + 1.0-78-g62d03d4 org.slf4j