Prevent PacketCollector leaking

in AbstractXMPPConnection.createPacketCollectorAndSend(IQ) in case there
is a NoResponseException.
This commit is contained in:
Florian Schmaus 2014-08-04 18:15:42 +02:00
parent 6caf2cbdb5
commit 70f1c22bb2
1 changed files with 8 additions and 2 deletions

View File

@ -654,8 +654,14 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
PacketFilter packetFilter = new IQReplyFilter(packet, this);
// Create the packet collector before sending the packet
PacketCollector packetCollector = createPacketCollector(packetFilter);
// Now we can send the packet as the collector has been created
sendPacket(packet);
try {
// Now we can send the packet as the collector has been created
sendPacket(packet);
}
catch (NotConnectedException e) {
packetCollector.cancel();
throw e;
}
return packetCollector;
}