Call XMPPConnection.sendIqRequestAndWaitForResponse(IQ) where possible

Refactored using

find . -type f -name "*.java" |\
	 xargs sed -i -E |\
		's/\.createStanzaCollectorAndSend\((\w+)\)\.nextResultOrThrow\(\);/.sendIqRequestAndWaitForResponse(\1);/'

and some manual refactoring.
master
Florian Schmaus 1 year ago
parent c9ea1c11b6
commit aab48570c9
  1. 2
      smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/CarbonManager.java
  2. 2
      smack-experimental/src/main/java/org/jivesoftware/smackx/httpfileupload/HttpFileUploadManager.java
  3. 2
      smack-experimental/src/main/java/org/jivesoftware/smackx/iot/control/IoTControlManager.java
  4. 2
      smack-experimental/src/main/java/org/jivesoftware/smackx/iot/data/IoTDataManager.java
  5. 10
      smack-experimental/src/main/java/org/jivesoftware/smackx/iot/discovery/IoTDiscoveryManager.java
  6. 2
      smack-experimental/src/main/java/org/jivesoftware/smackx/iot/provisioning/IoTProvisioningManager.java
  7. 4
      smack-experimental/src/main/java/org/jivesoftware/smackx/mam/MamManager.java
  8. 20
      smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLight.java
  9. 8
      smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java
  10. 2
      smack-experimental/src/main/java/org/jivesoftware/smackx/push_notifications/PushNotificationsManager.java
  11. 8
      smack-extensions/src/main/java/org/jivesoftware/smackx/blocking/BlockingCommandManager.java
  12. 2
      smack-extensions/src/main/java/org/jivesoftware/smackx/bob/BoBManager.java
  13. 2
      smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamManager.java
  14. 4
      smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSession.java
  15. 4
      smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamManager.java
  16. 2
      smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5ClientForInitiator.java
  17. 2
      smack-extensions/src/main/java/org/jivesoftware/smackx/commands/RemoteCommand.java
  18. 4
      smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java
  19. 2
      smack-extensions/src/main/java/org/jivesoftware/smackx/iqlast/LastActivityManager.java
  20. 6
      smack-extensions/src/main/java/org/jivesoftware/smackx/iqprivate/PrivateDataManager.java
  21. 2
      smack-extensions/src/main/java/org/jivesoftware/smackx/iqversion/VersionManager.java
  22. 32
      smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/JingleUtil.java
  23. 2
      smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/transports/jingle_s5b/JingleS5BTransportManager.java
  24. 8
      smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/transports/jingle_s5b/JingleS5BTransportSession.java
  25. 22
      smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java
  26. 6
      smack-extensions/src/main/java/org/jivesoftware/smackx/offline/OfflineMessageManager.java
  27. 4
      smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/PrivacyListManager.java
  28. 12
      smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/LeafNode.java
  29. 4
      smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Node.java
  30. 6
      smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java
  31. 6
      smack-extensions/src/main/java/org/jivesoftware/smackx/search/UserSearch.java
  32. 2
      smack-extensions/src/main/java/org/jivesoftware/smackx/sharedgroups/SharedGroupManager.java
  33. 2
      smack-extensions/src/main/java/org/jivesoftware/smackx/time/EntityTimeManager.java
  34. 4
      smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/VCardManager.java
  35. 11
      smack-extensions/src/testFixtures/java/org/jivesoftware/util/ConnectionUtils.java
  36. 4
      smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java
  37. 2
      smack-im/src/main/java/org/jivesoftware/smack/roster/RosterEntry.java
  38. 6
      smack-im/src/main/java/org/jivesoftware/smack/roster/RosterGroup.java
  39. 8
      smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/ContentNegotiator.java
  40. 4
      smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSession.java
  41. 7
      smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/listeners/JingleSessionListener.java
  42. 7
      smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/listeners/JingleTransportListener.java
  43. 3
      smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/BridgedResolver.java
  44. 5
      smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/BridgedTransportManager.java
  45. 5
      smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/ICETransportManager.java
  46. 34
      smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/RTPBridge.java
  47. 14
      smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/STUN.java
  48. 8
      smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/TransportNegotiator.java
  49. 6
      smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/Agent.java
  50. 36
      smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java
  51. 4
      smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/TranscriptManager.java
  52. 8
      smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/TranscriptSearchManager.java
  53. 20
      smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/user/Workgroup.java

@ -339,7 +339,7 @@ public final class CarbonManager extends Manager {
IQ setIQ = carbonsEnabledIQ(new_state);
connection().createStanzaCollectorAndSend(setIQ).nextResultOrThrow();
connection().sendIqRequestAndWaitForResponse(setIQ);
enabled_state = new_state;
}

@ -418,7 +418,7 @@ public final class HttpFileUploadManager extends Manager {
throw new AssertionError();
}
return connection.createStanzaCollectorAndSend(slotRequest).nextResultOrThrow();
return connection.sendIqRequestAndWaitForResponse(slotRequest);
}
public void setTlsContext(SSLContext tlsContext) {

@ -128,7 +128,7 @@ public final class IoTControlManager extends IoTManager {
public IoTSetResponse setUsingIq(FullJid jid, Collection<? extends SetData> data) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
IoTSetRequest request = new IoTSetRequest(data);
request.setTo(jid);
IoTSetResponse response = connection().createStanzaCollectorAndSend(request).nextResultOrThrow();
IoTSetResponse response = connection().sendIqRequestAndWaitForResponse(request);
return response;
}

@ -191,7 +191,7 @@ public final class IoTDataManager extends IoTManager {
StanzaCollector dataCollector = connection.createStanzaCollector(dataCollectorConfiguration);
try {
connection.createStanzaCollectorAndSend(iotDataRequest).nextResultOrThrow();
connection.sendIqRequestAndWaitForResponse(iotDataRequest);
// Wait until a message with an IoTFieldsExtension and the done flag comes in.
doneCollector.nextResult();
}

@ -246,7 +246,7 @@ public final class IoTDiscoveryManager extends Manager {
final XMPPConnection connection = connection();
IoTRegister iotRegister = new IoTRegister(thing.getMetaTags(), thing.getNodeInfo(), thing.isSelfOwened());
iotRegister.setTo(registry);
IQ result = connection.createStanzaCollectorAndSend(iotRegister).nextResultOrThrow();
IQ result = connection.sendIqRequestAndWaitForResponse(iotRegister);
if (result instanceof IoTClaimed) {
IoTClaimed iotClaimedResult = (IoTClaimed) result;
throw new IoTClaimedException(iotClaimedResult);
@ -293,7 +293,7 @@ public final class IoTDiscoveryManager extends Manager {
IoTMine iotMine = new IoTMine(metaTags, publicThing);
iotMine.setTo(registry);
IoTClaimed iotClaimed = connection().createStanzaCollectorAndSend(iotMine).nextResultOrThrow();
IoTClaimed iotClaimed = connection().sendIqRequestAndWaitForResponse(iotMine);
// The 'jid' attribute of the <claimed/> response now represents the XMPP address of the thing we just successfully claimed.
Jid thing = iotClaimed.getJid();
@ -322,7 +322,7 @@ public final class IoTDiscoveryManager extends Manager {
IoTRemove iotRemove = new IoTRemove(thing, nodeInfo);
iotRemove.setTo(registry);
connection().createStanzaCollectorAndSend(iotRemove).nextResultOrThrow();
connection().sendIqRequestAndWaitForResponse(iotRemove);
// We no not update the ThingState here, as this is done in the <removed/> IQ handler above.;
}
@ -346,7 +346,7 @@ public final class IoTDiscoveryManager extends Manager {
IoTUnregister iotUnregister = new IoTUnregister(nodeInfo);
iotUnregister.setTo(registry);
connection().createStanzaCollectorAndSend(iotUnregister).nextResultOrThrow();
connection().sendIqRequestAndWaitForResponse(iotUnregister);
ThingState state = getStateFor(nodeInfo);
state.setUnregistered();
@ -375,7 +375,7 @@ public final class IoTDiscoveryManager extends Manager {
IoTDisown iotDisown = new IoTDisown(thing, nodeInfo);
iotDisown.setTo(registry);
connection().createStanzaCollectorAndSend(iotDisown).nextResultOrThrow();
connection().sendIqRequestAndWaitForResponse(iotDisown);
}
// Registry utility methods

@ -344,7 +344,7 @@ public final class IoTProvisioningManager extends Manager {
IoTIsFriend iotIsFriend = new IoTIsFriend(friendInQuestion);
iotIsFriend.setTo(provisioningServer);
IoTIsFriendResponse response = connection().createStanzaCollectorAndSend(iotIsFriend).nextResultOrThrow();
IoTIsFriendResponse response = connection().sendIqRequestAndWaitForResponse(iotIsFriend);
assert response.getJid().equals(friendInQuestion);
boolean isFriend = response.getIsFriendResult();
if (!isFriend) {

@ -533,7 +533,7 @@ public final class MamManager extends Manager {
MamQueryIQ mamQueryIq = new MamQueryIQ(queryId, node, null);
mamQueryIq.setTo(archiveAddress);
MamQueryIQ mamResponseQueryIq = connection().createStanzaCollectorAndSend(mamQueryIq).nextResultOrThrow();
MamQueryIQ mamResponseQueryIq = connection().sendIqRequestAndWaitForResponse(mamQueryIq);
return mamResponseQueryIq.getDataForm().getFields();
}
@ -864,7 +864,7 @@ public final class MamManager extends Manager {
NotConnectedException, InterruptedException, NotLoggedInException {
final XMPPConnection connection = getAuthenticatedConnectionOrThrow();
MamPrefsIQ mamPrefsResultIQ = connection.createStanzaCollectorAndSend(mamPrefsIQ).nextResultOrThrow();
MamPrefsIQ mamPrefsResultIQ = connection.sendIqRequestAndWaitForResponse(mamPrefsIQ);
return new MamPrefsResult(mamPrefsResultIQ, DataForm.from(mamPrefsIQ));
}

@ -301,7 +301,7 @@ public class MultiUserChatLight {
messageCollector = connection.createStanzaCollector(fromRoomGroupChatFilter);
try {
connection.createStanzaCollectorAndSend(createMUCLightIQ).nextResultOrThrow();
connection.sendIqRequestAndWaitForResponse(createMUCLightIQ);
} catch (NotConnectedException | InterruptedException | NoResponseException | XMPPErrorException e) {
removeConnectionCallbacks();
throw e;
@ -332,7 +332,7 @@ public class MultiUserChatLight {
affiliations.put(connection.getUser(), MUCLightAffiliation.none);
MUCLightChangeAffiliationsIQ changeAffiliationsIQ = new MUCLightChangeAffiliationsIQ(room, affiliations);
IQ responseIq = connection.createStanzaCollectorAndSend(changeAffiliationsIQ).nextResultOrThrow();
IQ responseIq = connection.sendIqRequestAndWaitForResponse(changeAffiliationsIQ);
boolean roomLeft = responseIq.getType().equals(IQ.Type.result);
if (roomLeft) {
@ -354,7 +354,7 @@ public class MultiUserChatLight {
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
MUCLightGetInfoIQ mucLightGetInfoIQ = new MUCLightGetInfoIQ(room, version);
IQ responseIq = connection.createStanzaCollectorAndSend(mucLightGetInfoIQ).nextResultOrThrow();
IQ responseIq = connection.sendIqRequestAndWaitForResponse(mucLightGetInfoIQ);
MUCLightInfoIQ mucLightInfoResponseIQ = (MUCLightInfoIQ) responseIq;
return new MUCLightRoomInfo(mucLightInfoResponseIQ.getVersion(), room,
@ -388,7 +388,7 @@ public class MultiUserChatLight {
public MUCLightRoomConfiguration getConfiguration(String version)
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
MUCLightGetConfigsIQ mucLightGetConfigsIQ = new MUCLightGetConfigsIQ(room, version);
IQ responseIq = connection.createStanzaCollectorAndSend(mucLightGetConfigsIQ).nextResultOrThrow();
IQ responseIq = connection.sendIqRequestAndWaitForResponse(mucLightGetConfigsIQ);
MUCLightConfigurationIQ mucLightConfigurationIQ = (MUCLightConfigurationIQ) responseIq;
return mucLightConfigurationIQ.getConfiguration();
}
@ -421,7 +421,7 @@ public class MultiUserChatLight {
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
MUCLightGetAffiliationsIQ mucLightGetAffiliationsIQ = new MUCLightGetAffiliationsIQ(room, version);
IQ responseIq = connection.createStanzaCollectorAndSend(mucLightGetAffiliationsIQ).nextResultOrThrow();
IQ responseIq = connection.sendIqRequestAndWaitForResponse(mucLightGetAffiliationsIQ);
MUCLightAffiliationsIQ mucLightAffiliationsIQ = (MUCLightAffiliationsIQ) responseIq;
return mucLightAffiliationsIQ.getAffiliations();
@ -453,7 +453,7 @@ public class MultiUserChatLight {
public void changeAffiliations(HashMap<Jid, MUCLightAffiliation> affiliations)
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
MUCLightChangeAffiliationsIQ changeAffiliationsIQ = new MUCLightChangeAffiliationsIQ(room, affiliations);
connection.createStanzaCollectorAndSend(changeAffiliationsIQ).nextResultOrThrow();
connection.sendIqRequestAndWaitForResponse(changeAffiliationsIQ);
}
/**
@ -466,7 +466,7 @@ public class MultiUserChatLight {
*/
public void destroy() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
MUCLightDestroyIQ mucLightDestroyIQ = new MUCLightDestroyIQ(room);
IQ responseIq = connection.createStanzaCollectorAndSend(mucLightDestroyIQ).nextResultOrThrow();
IQ responseIq = connection.sendIqRequestAndWaitForResponse(mucLightDestroyIQ);
boolean roomDestroyed = responseIq.getType().equals(IQ.Type.result);
if (roomDestroyed) {
@ -486,7 +486,7 @@ public class MultiUserChatLight {
public void changeSubject(String subject)
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
MUCLightSetConfigsIQ mucLightSetConfigIQ = new MUCLightSetConfigsIQ(room, null, subject, null);
connection.createStanzaCollectorAndSend(mucLightSetConfigIQ).nextResultOrThrow();
connection.sendIqRequestAndWaitForResponse(mucLightSetConfigIQ);
}
/**
@ -501,7 +501,7 @@ public class MultiUserChatLight {
public void changeRoomName(String roomName)
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
MUCLightSetConfigsIQ mucLightSetConfigIQ = new MUCLightSetConfigsIQ(room, roomName, null);
connection.createStanzaCollectorAndSend(mucLightSetConfigIQ).nextResultOrThrow();
connection.sendIqRequestAndWaitForResponse(mucLightSetConfigIQ);
}
/**
@ -531,7 +531,7 @@ public class MultiUserChatLight {
public void setRoomConfigs(String roomName, HashMap<String, String> customConfigs)
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
MUCLightSetConfigsIQ mucLightSetConfigIQ = new MUCLightSetConfigsIQ(room, roomName, customConfigs);
connection.createStanzaCollectorAndSend(mucLightSetConfigIQ).nextResultOrThrow();
connection.sendIqRequestAndWaitForResponse(mucLightSetConfigIQ);
}
}

@ -279,7 +279,7 @@ public final class MultiUserChatLightManager extends Manager {
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(rooms, null);
mucLightBlockingIQ.setType(IQ.Type.set);
mucLightBlockingIQ.setTo(mucLightService);
connection().createStanzaCollectorAndSend(mucLightBlockingIQ).nextResultOrThrow();
connection().sendIqRequestAndWaitForResponse(mucLightBlockingIQ);
}
/**
@ -323,7 +323,7 @@ public final class MultiUserChatLightManager extends Manager {
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(null, users);
mucLightBlockingIQ.setType(IQ.Type.set);
mucLightBlockingIQ.setTo(mucLightService);
connection().createStanzaCollectorAndSend(mucLightBlockingIQ).nextResultOrThrow();
connection().sendIqRequestAndWaitForResponse(mucLightBlockingIQ);
}
/**
@ -367,7 +367,7 @@ public final class MultiUserChatLightManager extends Manager {
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(rooms, null);
mucLightBlockingIQ.setType(IQ.Type.set);
mucLightBlockingIQ.setTo(mucLightService);
connection().createStanzaCollectorAndSend(mucLightBlockingIQ).nextResultOrThrow();
connection().sendIqRequestAndWaitForResponse(mucLightBlockingIQ);
}
/**
@ -411,7 +411,7 @@ public final class MultiUserChatLightManager extends Manager {
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(null, users);
mucLightBlockingIQ.setType(IQ.Type.set);
mucLightBlockingIQ.setTo(mucLightService);
connection().createStanzaCollectorAndSend(mucLightBlockingIQ).nextResultOrThrow();
connection().sendIqRequestAndWaitForResponse(mucLightBlockingIQ);
}
}

@ -164,7 +164,7 @@ public final class PushNotificationsManager extends Manager {
private boolean changePushNotificationsStatus(IQ iq)
throws NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException {
final XMPPConnection connection = connection();
IQ responseIQ = connection.createStanzaCollectorAndSend(iq).nextResultOrThrow();
IQ responseIQ = connection.sendIqRequestAndWaitForResponse(iq);
return responseIQ.getType() != IQ.Type.error;
}

@ -184,7 +184,7 @@ public final class BlockingCommandManager extends Manager {
if (blockListCached == null) {
BlockListIQ blockListIQ = new BlockListIQ();
BlockListIQ blockListIQResult = connection().createStanzaCollectorAndSend(blockListIQ).nextResultOrThrow();
BlockListIQ blockListIQResult = connection().sendIqRequestAndWaitForResponse(blockListIQ);
blockListCached = blockListIQResult.getBlockedJidsCopy();
}
@ -203,7 +203,7 @@ public final class BlockingCommandManager extends Manager {
public void blockContacts(List<Jid> jids)
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
BlockContactsIQ blockContactIQ = new BlockContactsIQ(jids);
connection().createStanzaCollectorAndSend(blockContactIQ).nextResultOrThrow();
connection().sendIqRequestAndWaitForResponse(blockContactIQ);
}
/**
@ -218,7 +218,7 @@ public final class BlockingCommandManager extends Manager {
public void unblockContacts(List<Jid> jids)
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
UnblockContactsIQ unblockContactIQ = new UnblockContactsIQ(jids);
connection().createStanzaCollectorAndSend(unblockContactIQ).nextResultOrThrow();
connection().sendIqRequestAndWaitForResponse(unblockContactIQ);
}
/**
@ -232,7 +232,7 @@ public final class BlockingCommandManager extends Manager {
public void unblockAll()
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
UnblockContactsIQ unblockContactIQ = new UnblockContactsIQ();
connection().createStanzaCollectorAndSend(unblockContactIQ).nextResultOrThrow();
connection().sendIqRequestAndWaitForResponse(unblockContactIQ);
}
public void addJidsBlockedListener(JidsBlockedListener jidsBlockedListener) {

@ -149,7 +149,7 @@ public final class BoBManager extends Manager {
requestBoBIQ.setTo(to);
XMPPConnection connection = getAuthenticatedConnectionOrThrow();
BoBIQ responseBoBIQ = connection.createStanzaCollectorAndSend(requestBoBIQ).nextResultOrThrow();
BoBIQ responseBoBIQ = connection.sendIqRequestAndWaitForResponse(requestBoBIQ);
bobData = responseBoBIQ.getBoBData();
BOB_CACHE.put(bobHash, bobData);

@ -424,7 +424,7 @@ public final class InBandBytestreamManager extends Manager implements Bytestream
final XMPPConnection connection = connection();
// sending packet will throw exception on timeout or error reply
connection.createStanzaCollectorAndSend(byteStreamRequest).nextResultOrThrow();
connection.sendIqRequestAndWaitForResponse(byteStreamRequest);
InBandBytestreamSession inBandBytestreamSession = new InBandBytestreamSession(
connection, byteStreamRequest, targetJID);

@ -228,7 +228,7 @@ public class InBandBytestreamSession implements BytestreamSession {
Close close = new Close(this.byteStreamRequest.getSessionID());
close.setTo(this.remoteJID);
try {
connection.createStanzaCollectorAndSend(close).nextResultOrThrow();
connection.sendIqRequestAndWaitForResponse(close);
}
catch (Exception e) {
// Sadly we are unable to use the IOException(Throwable) constructor because this
@ -823,7 +823,7 @@ public class InBandBytestreamSession implements BytestreamSession {
iq.setTo(remoteJID);
try {
connection.createStanzaCollectorAndSend(iq).nextResultOrThrow();
connection.sendIqRequestAndWaitForResponse(iq);
}
catch (Exception e) {
// close session unless it is already closed

@ -624,8 +624,8 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
for (Jid proxy : proxies) {
Bytestream streamHostRequest = createStreamHostRequest(proxy);
try {
Bytestream response = connection.createStanzaCollectorAndSend(
streamHostRequest).nextResultOrThrow();
Bytestream response = connection.sendIqRequestAndWaitForResponse(
streamHostRequest);
streamHosts.addAll(response.getStreamHosts());
}
catch (Exception e) {

@ -115,7 +115,7 @@ public class Socks5ClientForInitiator extends Socks5Client {
private void activate() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
Bytestream activate = createStreamHostActivation();
// if activation fails #nextResultOrThrow() throws an exception
connection.get().createStanzaCollectorAndSend(activate).nextResultOrThrow();
connection.get().sendIqRequestAndWaitForResponse(activate);
}
/**

@ -145,7 +145,7 @@ public class RemoteCommand extends AdHocCommand {
AdHocCommandData responseData = null;
try {
responseData = connection.createStanzaCollectorAndSend(data).nextResultOrThrow();
responseData = connection.sendIqRequestAndWaitForResponse(data);
}
finally {
// We set the response data in a 'finally' block, so that it also gets set even if an error IQ was returned.

@ -603,7 +603,7 @@ public final class ServiceDiscoveryManager extends Manager {
.setNode(node)
.build();
Stanza result = connection.createStanzaCollectorAndSend(discoInfoRequest).nextResultOrThrow();
Stanza result = connection.sendIqRequestAndWaitForResponse(discoInfoRequest);
return (DiscoverInfo) result;
}
@ -642,7 +642,7 @@ public final class ServiceDiscoveryManager extends Manager {
disco.setTo(entityID);
disco.setNode(node);
Stanza result = connection().createStanzaCollectorAndSend(disco).nextResultOrThrow();
Stanza result = connection().sendIqRequestAndWaitForResponse(disco);
return (DiscoverItems) result;
}

@ -236,7 +236,7 @@ public final class LastActivityManager extends Manager {
public LastActivity getLastActivity(Jid jid) throws NoResponseException, XMPPErrorException,
NotConnectedException, InterruptedException {
LastActivity activity = new LastActivity(jid);
return (LastActivity) connection().createStanzaCollectorAndSend(activity).nextResultOrThrow();
return (LastActivity) connection().sendIqRequestAndWaitForResponse(activity);
}
/**

@ -163,8 +163,8 @@ public final class PrivateDataManager extends Manager {
// Create an IQ packet to get the private data.
IQ privateDataGet = new PrivateDataIQ(elementName, namespace);
PrivateDataIQ response = connection().createStanzaCollectorAndSend(
privateDataGet).nextResultOrThrow();
PrivateDataIQ response = connection().sendIqRequestAndWaitForResponse(
privateDataGet);
return response.getPrivateData();
}
@ -183,7 +183,7 @@ public final class PrivateDataManager extends Manager {
// Create an IQ packet to set the private data.
IQ privateDataSet = new PrivateDataIQ(privateData);
connection().createStanzaCollectorAndSend(privateDataSet).nextResultOrThrow();
connection().sendIqRequestAndWaitForResponse(privateDataSet);
}
private static final PrivateData DUMMY_PRIVATE_DATA = new PrivateData() {

@ -155,7 +155,7 @@ public final class VersionManager extends Manager {
}
XMPPConnection connection = connection();
Version version = Version.builder(connection).to(jid).build();
return connection().createStanzaCollectorAndSend(version).nextResultOrThrow();
return connection().sendIqRequestAndWaitForResponse(version);
}
private static VersionInformation generateVersionFrom(String name, String version, String os) {

@ -90,7 +90,7 @@ public class JingleUtil {
XMPPException.XMPPErrorException, SmackException.NoResponseException {
Jingle jingle = createSessionInitiateFileOffer(recipient, sessionId, contentCreator, contentName, description, transport);
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
return connection.sendIqRequestAndWaitForResponse(jingle);
}
public IQ sendSessionInitiate(FullJid recipient,
@ -176,7 +176,7 @@ public class JingleUtil {
XMPPException.XMPPErrorException, SmackException.NoResponseException {
Jingle jingle = createSessionTerminateDecline(recipient, sessionId);
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
return connection.sendIqRequestAndWaitForResponse(jingle);
}
public Jingle createSessionTerminateSuccess(FullJid recipient, String sessionId) {
@ -188,7 +188,7 @@ public class JingleUtil {
SmackException.NotConnectedException, SmackException.NoResponseException {
Jingle jingle = createSessionTerminateSuccess(recipient, sessionId);
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
return connection.sendIqRequestAndWaitForResponse(jingle);
}
public Jingle createSessionTerminateBusy(FullJid recipient, String sessionId) {
@ -200,7 +200,7 @@ public class JingleUtil {
SmackException.NotConnectedException, SmackException.NoResponseException {
Jingle jingle = createSessionTerminateBusy(recipient, sessionId);
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
return connection.sendIqRequestAndWaitForResponse(jingle);
}
public Jingle createSessionTerminateAlternativeSession(FullJid recipient, String sessionId, String altSessionId) {
@ -212,7 +212,7 @@ public class JingleUtil {
SmackException.NotConnectedException, SmackException.NoResponseException {
Jingle jingle = createSessionTerminateAlternativeSession(recipient, sessionId, altSessionId);
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
return connection.sendIqRequestAndWaitForResponse(jingle);
}
public Jingle createSessionTerminateCancel(FullJid recipient, String sessionId) {
@ -225,7 +225,7 @@ public class JingleUtil {
SmackException.NotConnectedException, SmackException.NoResponseException {
Jingle jingle = createSessionTerminateCancel(recipient, sessionId);
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
return connection.sendIqRequestAndWaitForResponse(jingle);
}
public Jingle createSessionTerminateContentCancel(FullJid recipient, String sessionId,
@ -249,7 +249,7 @@ public class JingleUtil {
throws SmackException.NotConnectedException, InterruptedException,
XMPPException.XMPPErrorException, SmackException.NoResponseException {
Jingle jingle = createSessionTerminateContentCancel(recipient, sessionId, contentCreator, contentName);
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
return connection.sendIqRequestAndWaitForResponse(jingle);
}
public Jingle createSessionTerminateUnsupportedTransports(FullJid recipient, String sessionId) {
@ -260,7 +260,7 @@ public class JingleUtil {
throws InterruptedException, XMPPException.XMPPErrorException,
SmackException.NotConnectedException, SmackException.NoResponseException {
Jingle jingle = createSessionTerminateUnsupportedTransports(recipient, sessionId);
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
return connection.sendIqRequestAndWaitForResponse(jingle);
}
public Jingle createSessionTerminateFailedTransport(FullJid recipient, String sessionId) {
@ -271,7 +271,7 @@ public class JingleUtil {
throws InterruptedException, XMPPException.XMPPErrorException,
SmackException.NotConnectedException, SmackException.NoResponseException {
Jingle jingle = createSessionTerminateFailedTransport(recipient, sessionId);
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
return connection.sendIqRequestAndWaitForResponse(jingle);
}
public Jingle createSessionTerminateUnsupportedApplications(FullJid recipient, String sessionId) {
@ -282,7 +282,7 @@ public class JingleUtil {
throws InterruptedException, XMPPException.XMPPErrorException,
SmackException.NotConnectedException, SmackException.NoResponseException {
Jingle jingle = createSessionTerminateUnsupportedApplications(recipient, sessionId);
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
return connection.sendIqRequestAndWaitForResponse(jingle);
}
public Jingle createSessionTerminateFailedApplication(FullJid recipient, String sessionId) {
@ -293,7 +293,7 @@ public class JingleUtil {
throws InterruptedException, XMPPException.XMPPErrorException,
SmackException.NotConnectedException, SmackException.NoResponseException {
Jingle jingle = createSessionTerminateFailedApplication(recipient, sessionId);
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
return connection.sendIqRequestAndWaitForResponse(jingle);
}
public Jingle createSessionTerminateIncompatibleParameters(FullJid recipient, String sessionId) {
@ -304,7 +304,7 @@ public class JingleUtil {
throws InterruptedException, XMPPException.XMPPErrorException,
SmackException.NotConnectedException, SmackException.NoResponseException {
Jingle jingle = createSessionTerminateIncompatibleParameters(recipient, sessionId);
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
return connection.sendIqRequestAndWaitForResponse(jingle);
}
public IQ sendContentRejectFileNotAvailable(FullJid recipient, String sessionId, JingleContentDescription description) {
@ -327,7 +327,7 @@ public class JingleUtil {
throws SmackException.NotConnectedException, InterruptedException,
XMPPException.XMPPErrorException, SmackException.NoResponseException {
Jingle jingle = createSessionPing(recipient, sessionId);
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
return connection.sendIqRequestAndWaitForResponse(jingle);
}
public IQ createAck(Jingle jingle) {
@ -362,7 +362,7 @@ public class JingleUtil {
throws SmackException.NotConnectedException, InterruptedException,
XMPPException.XMPPErrorException, SmackException.NoResponseException {
Jingle jingle = createTransportReplace(recipient, initiator, sessionId, contentCreator, contentName, transport);
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
return connection.sendIqRequestAndWaitForResponse(jingle);
}
public Jingle createTransportAccept(FullJid recipient, FullJid initiator, String sessionId,
@ -389,7 +389,7 @@ public class JingleUtil {
throws SmackException.NotConnectedException, InterruptedException,
XMPPException.XMPPErrorException, SmackException.NoResponseException {
Jingle jingle = createTransportAccept(recipient, initiator, sessionId, contentCreator, contentName, transport);
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
return connection.sendIqRequestAndWaitForResponse(jingle);
}
public Jingle createTransportReject(FullJid recipient, FullJid initiator, String sessionId,
@ -416,7 +416,7 @@ public class JingleUtil {
throws SmackException.NotConnectedException, InterruptedException,
XMPPException.XMPPErrorException, SmackException.NoResponseException {
Jingle jingle = createTransportReject(recipient, initiator, sessionId, contentCreator, contentName, transport);
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
return connection.sendIqRequestAndWaitForResponse(jingle);
}
/*

@ -119,7 +119,7 @@ public final class JingleS5BTransportManager extends JingleTransportManager<Jing
request.setType(IQ.Type.get);
request.setTo(proxy);
try {
Bytestream response = connection.createStanzaCollectorAndSend(request).nextResultOrThrow();
Bytestream response = connection.sendIqRequestAndWaitForResponse(request);
streamHosts.addAll(response.getStreamHosts());
}
catch (Exception e) {

@ -137,8 +137,7 @@ public class JingleS5BTransportSession extends JingleTransportSession<JingleS5BT
Jingle jingle = transportManager().createCandidateUsed(jingleSession.getRemote(), jingleSession.getInitiator(), jingleSession.getSessionId(),
content.getSenders(), content.getCreator(), content.getName(), theirProposal.getStreamId(), ourChoice.candidate.getCandidateId());
try {
jingleSession.getConnection().createStanzaCollectorAndSend(jingle)
.nextResultOrThrow();
jingleSession.getConnection().sendIqRequestAndWaitForResponse(jingle);
} catch (InterruptedException | XMPPException.XMPPErrorException | SmackException.NotConnectedException | SmackException.NoResponseException e) {
LOGGER.log(Level.WARNING, "Could not send candidate-used.", e);
}
@ -303,7 +302,7 @@ public class JingleS5BTransportSession extends JingleTransportSession<JingleS5BT
activate.setToActivate(jingleSession.getRemote());
activate.setFrom(jingleSession.getLocal());
try {
jingleSession.getConnection().createStanzaCollectorAndSend(activate).nextResultOrThrow();
jingleSession.getConnection().sendIqRequestAndWaitForResponse(activate);
} catch (InterruptedException | XMPPException.XMPPErrorException | SmackException.NotConnectedException | SmackException.NoResponseException e) {
LOGGER.log(Level.WARNING, "Could not activate proxy.", e);
return;
@ -315,8 +314,7 @@ public class JingleS5BTransportSession extends JingleTransportSession<JingleS5BT
content.getSenders(), content.getCreator(), content.getName(), nominated.transport.getStreamId(),
nominated.candidate.getCandidateId());
try {
jingleSession.getConnection().createStanzaCollectorAndSend(candidateActivate)
.nextResultOrThrow();
jingleSession.getConnection().sendIqRequestAndWaitForResponse(candidateActivate);
} catch (InterruptedException | XMPPException.XMPPErrorException | SmackException.NotConnectedException | SmackException.NoResponseException e) {
LOGGER.log(Level.WARNING, "Could not send candidate-activated", e);
return;

@ -838,7 +838,7 @@ public class MultiUserChat {
iq.setTo(room);
iq.setType(IQ.Type.get);
IQ answer = connection.createStanzaCollectorAndSend(iq).nextResultOrThrow();
IQ answer = connection.sendIqRequestAndWaitForResponse(iq);
DataForm dataForm = DataForm.from(answer, MucConfigFormManager.FORM_TYPE);
return new Form(dataForm);
}
@ -867,7 +867,7 @@ public class MultiUserChat {
iq.setType(IQ.Type.set);
iq.addExtension(dataForm);
connection.createStanzaCollectorAndSend(iq).nextResultOrThrow();
connection.sendIqRequestAndWaitForResponse(iq);
}
/**
@ -892,7 +892,7 @@ public class MultiUserChat {
reg.setType(IQ.Type.get);
reg.setTo(room);
IQ result = connection.createStanzaCollectorAndSend(reg).nextResultOrThrow();
IQ result = connection.sendIqRequestAndWaitForResponse(reg);
DataForm dataForm = DataForm.from(result);
return new Form(dataForm);
}
@ -920,7 +920,7 @@ public class MultiUserChat {
reg.setTo(room);
reg.addExtension(form.getDataFormToSubmit());
connection.createStanzaCollectorAndSend(reg).nextResultOrThrow();
connection.sendIqRequestAndWaitForResponse(reg);
}
/**
@ -965,7 +965,7 @@ public class MultiUserChat {
iq.setDestroy(destroy);
try {
connection.createStanzaCollectorAndSend(iq).nextResultOrThrow();
connection.sendIqRequestAndWaitForResponse(iq);
}
catch (XMPPErrorException e) {
// Note that we do not call userHasLeft() here because an XMPPErrorException would usually indicate that the
@ -1718,7 +1718,7 @@ public class MultiUserChat {
MUCItem item = new MUCItem(affiliation, jid, reason);
iq.addItem(item);
connection.createStanzaCollectorAndSend(iq).nextResultOrThrow();
connection.sendIqRequestAndWaitForResponse(iq);
}
private void changeAffiliationByAdmin(Collection<? extends Jid> jids, MUCAffiliation affiliation)
@ -1732,7 +1732,7 @@ public class MultiUserChat {
iq.addItem(item);
}
connection.createStanzaCollectorAndSend(iq).nextResultOrThrow();
connection.sendIqRequestAndWaitForResponse(iq);
}
private void changeRole(Resourcepart nickname, MUCRole role, String reason) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
@ -1743,7 +1743,7 @@ public class MultiUserChat {
MUCItem item = new MUCItem(role, nickname, reason);
iq.addItem(item);
connection.createStanzaCollectorAndSend(iq).nextResultOrThrow();
connection.sendIqRequestAndWaitForResponse(iq);
}
private void changeRole(Collection<Resourcepart> nicknames, MUCRole role) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
@ -1756,7 +1756,7 @@ public class MultiUserChat {
iq.addItem(item);
}
connection.createStanzaCollectorAndSend(iq).nextResultOrThrow();
connection.sendIqRequestAndWaitForResponse(iq);
}
/**
@ -1914,7 +1914,7 @@ public class MultiUserChat {
MUCItem item = new MUCItem(affiliation);
iq.addItem(item);
MUCAdmin answer = (MUCAdmin) connection.createStanzaCollectorAndSend(iq).nextResultOrThrow();
MUCAdmin answer = (MUCAdmin) connection.sendIqRequestAndWaitForResponse(iq);
// Get the list of affiliates from the server's answer
List<Affiliate> affiliates = new ArrayList<Affiliate>();
@ -1969,7 +1969,7 @@ public class MultiUserChat {
MUCItem item = new MUCItem(role);
iq.addItem(item);
MUCAdmin answer = (MUCAdmin) connection.createStanzaCollectorAndSend(iq).nextResultOrThrow();
MUCAdmin answer = (MUCAdmin) connection.sendIqRequestAndWaitForResponse(iq);
// Get the list of participants from the server's answer
List<Occupant> participants = new ArrayList<Occupant>();
for (MUCItem mucadminItem : answer.getItems()) {

@ -178,7 +178,7 @@ public final class OfflineMessageManager extends Manager {
});
int pendingNodes = nodes.size();
try (StanzaCollector messageCollector = connection().createStanzaCollector(messageFilter)) {
connection().createStanzaCollectorAndSend(request).nextResultOrThrow();
connection().sendIqRequestAndWaitForResponse(request);
// Collect the received offline messages
Message message;
do {
@ -249,7 +249,7 @@ public final class OfflineMessageManager extends Manager {
item.setAction("remove");
request.addItem(item);
}
connection().createStanzaCollectorAndSend(request).nextResultOrThrow();
connection().sendIqRequestAndWaitForResponse(request);
}
/**
@ -265,6 +265,6 @@ public final class OfflineMessageManager extends Manager {
OfflineMessageRequest request = new OfflineMessageRequest();
request.setType(IQ.Type.set);
request.setPurge(true);
connection().createStanzaCollectorAndSend(request).nextResultOrThrow();
connection().sendIqRequestAndWaitForResponse(request);
}
}

@ -233,7 +233,7 @@ public final class PrivacyListManager extends Manager {
// The request is a get iq type
requestPrivacy.setType(Privacy.Type.get);
return connection().createStanzaCollectorAndSend(requestPrivacy).nextResultOrThrow();
return connection().sendIqRequestAndWaitForResponse(requestPrivacy);
}
/**
@ -252,7 +252,7 @@ public final class PrivacyListManager extends Manager {
// The request is a get iq type
requestPrivacy.setType(Privacy.Type.set);
return connection().createStanzaCollectorAndSend(requestPrivacy).nextResultOrThrow();
return connection().sendIqRequestAndWaitForResponse(requestPrivacy);
}
/**

@ -57,7 +57,7 @@ public class LeafNode extends Node {
DiscoverItems items = new DiscoverItems();
items.setTo(pubSubManager.getServiceJid());
items.setNode(getId());
return pubSubManager.getConnection().createStanzaCollectorAndSend(items).nextResultOrThrow();
return pubSubManager.getConnection().sendIqRequestAndWaitForResponse(items);
}
/**
@ -194,7 +194,7 @@ public class LeafNode extends Node {
private <T extends Item> List<T> getItems(PubSub request,
List<XmlElement> returnedExtensions) throws NoResponseException,
XMPPErrorException, NotConnectedException, InterruptedException {
PubSub result = pubSubManager.getConnection().createStanzaCollectorAndSend(request).nextResultOrThrow();
PubSub result = pubSubManager.getConnection().sendIqRequestAndWaitForResponse(request);
ItemsExtension itemsElem = result.getExtension(PubSubElementType.ITEMS);
if (returnedExtensions != null) {
returnedExtensions.addAll(result.getExtensions());
@ -278,7 +278,7 @@ public class LeafNode extends Node {
public void publish() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
PubSub packet = createPubsubPacket(IQ.Type.set, new NodeExtension(PubSubElementType.PUBLISH, getId()));
pubSubManager.getConnection().createStanzaCollectorAndSend(packet).nextResultOrThrow();
pubSubManager.getConnection().sendIqRequestAndWaitForResponse(packet);
}
/**
@ -327,7 +327,7 @@ public class LeafNode extends Node {
public <T extends Item> void publish(Collection<T> items) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
PubSub packet = createPubsubPacket(IQ.Type.set, new PublishItem<>(getId(), items));
pubSubManager.getConnection().createStanzaCollectorAndSend(packet).nextResultOrThrow();
pubSubManager.getConnection().sendIqRequestAndWaitForResponse(packet);
}
/**
@ -343,7 +343,7 @@ public class LeafNode extends Node {
public void deleteAllItems() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
PubSub request = createPubsubPacket(IQ.Type.set, new NodeExtension(PubSubElementType.PURGE_OWNER, getId()));
pubSubManager.getConnection().createStanzaCollectorAndSend(request).nextResultOrThrow();
pubSubManager.getConnection().sendIqRequestAndWaitForResponse(request);
}
/**
@ -377,6 +377,6 @@ public class LeafNode extends Node {
items.add(new Item(id));
}
PubSub request = createPubsubPacket(IQ.Type.set, new ItemsExtension(ItemsExtension.ItemsElementType.retract, getId(), items));
pubSubManager.getConnection().createStanzaCollectorAndSend(request).nextResultOrThrow();
pubSubManager.getConnection().sendIqRequestAndWaitForResponse(request);
}
}

@ -112,7 +112,7 @@ public abstract class Node {
public void sendConfigurationForm(FillableConfigureForm configureForm) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
PubSub packet = createPubsubPacket(IQ.Type.set, new FormNode(FormNodeType.CONFIGURE_OWNER,
getId(), configureForm.getDataFormToSubmit()));
pubSubManager.getConnection().createStanzaCollectorAndSend(packet).nextResultOrThrow();
pubSubManager.getConnection().sendIqRequestAndWaitForResponse(packet);
}
/**
@ -130,7 +130,7 @@ public abstract class Node {
.to(pubSubManager.getServiceJid())
.setNode(getId())
.build();
return connection.createStanzaCollectorAndSend(discoverInfoRequest).nextResultOrThrow();
return connection.sendIqRequestAndWaitForResponse(discoverInfoRequest);
}
/**

@ -302,7 +302,7 @@ public final class PubSubManager extends Manager {
.setNode(id)
.build();
DiscoverInfo infoReply = connection.createStanzaCollectorAndSend(info).nextResultOrThrow();
DiscoverInfo infoReply = connection.sendIqRequestAndWaitForResponse(info);
if (infoReply.hasIdentity(PubSub.ELEMENT, "leaf")) {
node = new LeafNode(this, id);
@ -492,7 +492,7 @@ public final class PubSubManager extends Manager {
if (nodeId != null)
items.setNode(nodeId);
items.setTo(pubSubService);
DiscoverItems nodeItems = connection().createStanzaCollectorAndSend(items).nextResultOrThrow();
DiscoverItems nodeItems = connection().sendIqRequestAndWaitForResponse(items);
return nodeItems;
}
@ -666,7 +666,7 @@ public final class PubSubManager extends Manager {
PubSub sendPubsubPacket(PubSub packet) throws NoResponseException, XMPPErrorException,
NotConnectedException, InterruptedException {
IQ resultIQ = connection().createStanzaCollectorAndSend(packet).nextResultOrThrow();
IQ resultIQ = connection().sendIqRequestAndWaitForResponse(packet);
if (resultIQ instanceof EmptyResultIQ) {
return null;
}

@ -73,7 +73,7 @@ public class UserSearch extends SimpleIQ {
search.setType(IQ.Type.get);
search.setTo(searchService);
IQ response = con.createStanzaCollectorAndSend(search).nextResultOrThrow();
IQ response = con.sendIqRequestAndWaitForResponse(search);
return DataForm.from(response, NAMESPACE);
}
@ -95,7 +95,7 @@ public class UserSearch extends SimpleIQ {
search.setTo(searchService);
search.addExtension(searchForm);
IQ response = con.createStanzaCollectorAndSend(search).nextResultOrThrow();
IQ response = con.sendIqRequestAndWaitForResponse(search);
return ReportedData.getReportedDataFrom(response);
}
@ -117,7 +117,7 @@ public class UserSearch extends SimpleIQ {
search.setType(IQ.Type.set);
search.setTo(searchService);
SimpleUserSearch response = con.createStanzaCollectorAndSend(search).nextResultOrThrow();
SimpleUserSearch response = con.sendIqRequestAndWaitForResponse(search);
return response.getReportedData();
}

@ -52,7 +52,7 @@ public class SharedGroupManager {
SharedGroupsInfo info = new SharedGroupsInfo();
info.setType(IQ.Type.get);
SharedGroupsInfo result = connection.createStanzaCollectorAndSend(info).nextResultOrThrow();
SharedGroupsInfo result = connection.sendIqRequestAndWaitForResponse(info);
return result.getGroups();
}
}

@ -118,6 +118,6 @@ public final class EntityTimeManager extends Manager {
Time request = Time.builder(connection)
.to(jid)
.build();
return connection.createStanzaCollectorAndSend(request).nextResultOrThrow();
return connection.sendIqRequestAndWaitForResponse(request);
}
}

@ -107,7 +107,7 @@ public final class VCardManager extends Manager {
// Also make sure to generate a new stanza id (the given vcard could be a vcard result), in which case we don't
// want to use the same stanza id again (although it wouldn't break if we did)
vcard.setStanzaId();
connection().createStanzaCollectorAndSend(vcard).nextResultOrThrow();
connection().sendIqRequestAndWaitForResponse(vcard);
}
/**
@ -137,7 +137,7 @@ public final class VCardManager extends Manager {
public VCard loadVCard(EntityBareJid bareJid) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
VCard vcardRequest = new VCard();
vcardRequest.setTo(bareJid);
VCard result = connection().createStanzaCollectorAndSend(vcardRequest).nextResultOrThrow();
VCard result = connection().sendIqRequestAndWaitForResponse(vcardRequest);
return result;
}

@ -129,6 +129,17 @@ public class ConnectionUtils {
when(collector.nextResultOrThrow()).thenAnswer(answerOrThrow);
when(collector.nextResultOrThrow(anyLong())).thenAnswer(answerOrThrow);
Answer<IQ> responseIq = new Answer<IQ>() {
@Override
public IQ answer(InvocationOnMock invocation) throws Throwable {
collectorAndSend.answer(invocation);
IQ response = (IQ) answerOrThrow.answer(invocation);
return response;
}
};
when(connection.sendIqRequestAndWaitForResponse(isA(IQ.class))).thenAnswer(responseIq);
// initialize service discovery manager for this connection
ServiceDiscoveryManager.getInstanceFor(connection);

@ -699,7 +699,7 @@ public final class Roster extends Manager {
}
}
rosterPacket.addRosterItem(item);
connection.createStanzaCollectorAndSend(rosterPacket).nextResultOrThrow();
connection.sendIqRequestAndWaitForResponse(rosterPacket);
}
/**
@ -852,7 +852,7 @@ public final class Roster extends Manager {
// Set the item type as REMOVE so that the server will delete the entry
item.setItemType(RosterPacket.ItemType.remove);
packet.addRosterItem(item);
connection.createStanzaCollectorAndSend(packet).nextResultOrThrow();
connection.sendIqRequestAndWaitForResponse(packet);
}
/**

@ -110,7 +110,7 @@ public final class RosterEntry extends Manager {
// Create a new roster item with the current RosterEntry and the *new* name. Note that we can't set the name of
// RosterEntry right away, as otherwise the updated event wont get fired, because equalsDeep would return true.
packet.addRosterItem(toRosterItem(this, name));
connection().createStanzaCollectorAndSend(packet).nextResultOrThrow();
connection().sendIqRequestAndWaitForResponse(packet);
// We have received a result response to the IQ set, the name was successfully changed
item.setName(name);