From 4a857fe67aeac4c2aa89ddd82a8806205719d02a Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Fri, 5 Jun 2015 08:14:51 +0200 Subject: [PATCH] Assert that a Stanza is a Stanza in sendStanza --- .../smack/AbstractXMPPConnection.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java index 43aa0e071..3d14499df 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java @@ -62,6 +62,7 @@ import org.jivesoftware.smack.packet.Bind; import org.jivesoftware.smack.packet.ErrorIQ; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.Mechanisms; +import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.packet.Presence; @@ -622,25 +623,26 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { } @Override - public void sendStanza(Stanza packet) throws NotConnectedException, InterruptedException { - Objects.requireNonNull(packet, "Packet must not be null"); + public void sendStanza(Stanza stanza) throws NotConnectedException, InterruptedException { + Objects.requireNonNull(stanza, "Stanza must not be null"); + assert(stanza instanceof Message || stanza instanceof Presence || stanza instanceof IQ); throwNotConnectedExceptionIfAppropriate(); switch (fromMode) { case OMITTED: - packet.setFrom((Jid) null); + stanza.setFrom((Jid) null); break; case USER: - packet.setFrom(getUser()); + stanza.setFrom(getUser()); break; case UNCHANGED: default: break; } - // Invoke interceptors for the new packet that is about to be sent. Interceptors may modify - // the content of the packet. - firePacketInterceptors(packet); - sendStanzaInternal(packet); + // Invoke interceptors for the new stanza that is about to be sent. Interceptors may modify + // the content of the stanza. + firePacketInterceptors(stanza); + sendStanzaInternal(stanza); } /**