Ensure that IQ response 'to' address and ID are set correctly

Fixes SMACK-845.
This commit is contained in:
Florian Schmaus 2018-12-14 17:18:53 +01:00
parent 5ddaa623da
commit f6da386dea
1 changed files with 6 additions and 0 deletions

View File

@ -1097,6 +1097,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
if (packet instanceof IQ) {
final IQ iq = (IQ) packet;
if (iq.isRequestIQ()) {
final IQ iqRequest = iq;
final String key = XmppStringUtils.generateKey(iq.getChildElementName(), iq.getChildElementNamespace());
IQRequestHandler iqRequestHandler;
final IQ.Type type = iq.getType();
@ -1162,6 +1163,11 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
// e.g. to avoid presence leaks.
return;
}
assert (response.getType() == IQ.Type.result || response.getType() == IQ.Type.error);
response.setTo(iqRequest.getFrom());
response.setStanzaId(iqRequest.getStanzaId());
try {
sendStanza(response);
}