mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-22 10:37:59 +01:00
Add reply timeout to NoResponseException message
This commit is contained in:
parent
c81cd34561
commit
def8fea05f
6 changed files with 16 additions and 14 deletions
|
@ -1185,7 +1185,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
// If the packetListener got removed, then it was never run and
|
||||
// we never received a response, inform the exception callback
|
||||
if (removed && exceptionCallback != null) {
|
||||
exceptionCallback.processException(new NoResponseException());
|
||||
exceptionCallback.processException(new NoResponseException(AbstractXMPPConnection.this));
|
||||
}
|
||||
}
|
||||
}, timeout, TimeUnit.MILLISECONDS);
|
||||
|
|
|
@ -191,7 +191,7 @@ public class PacketCollector {
|
|||
P result = nextResult(timeout);
|
||||
cancel();
|
||||
if (result == null) {
|
||||
throw new NoResponseException();
|
||||
throw new NoResponseException(connection);
|
||||
}
|
||||
|
||||
XMPPErrorException.ifHasErrorThenThrow(result);
|
||||
|
|
|
@ -197,7 +197,7 @@ public class SASLAuthentication {
|
|||
maybeThrowException();
|
||||
|
||||
if (!authenticationSuccessful) {
|
||||
throw new NoResponseException();
|
||||
throw new NoResponseException(connection);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -244,7 +244,7 @@ public class SASLAuthentication {
|
|||
maybeThrowException();
|
||||
|
||||
if (!authenticationSuccessful) {
|
||||
throw new NoResponseException();
|
||||
throw new NoResponseException(connection);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -283,7 +283,7 @@ public class SASLAuthentication {
|
|||
maybeThrowException();
|
||||
|
||||
if (!authenticationSuccessful) {
|
||||
throw new NoResponseException();
|
||||
throw new NoResponseException(connection);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,8 +54,9 @@ public class SmackException extends Exception {
|
|||
}
|
||||
|
||||
/**
|
||||
* Exception thrown always when there was no response to an (IQ) request within the packet reply
|
||||
* timeout of the used connection instance.
|
||||
* Exception thrown always when there was no response to an request within the packet reply timeout of the used
|
||||
* connection instance. You can modify (e.g. increase) the packet reply timeout with
|
||||
* {@link XMPPConnection#setPacketReplyTimeout(long)}.
|
||||
*/
|
||||
public static class NoResponseException extends SmackException {
|
||||
/**
|
||||
|
@ -63,8 +64,9 @@ public class SmackException extends Exception {
|
|||
*/
|
||||
private static final long serialVersionUID = -6523363748984543636L;
|
||||
|
||||
public NoResponseException() {
|
||||
super("No response received within packet reply timeout");
|
||||
public NoResponseException(XMPPConnection connection) {
|
||||
super("No response received within packet reply timeout. Timeout was " + connection.getPacketReplyTimeout()
|
||||
+ "ms (~" + connection.getPacketReplyTimeout() / 1000 + "s)");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ public class SynchronizationPoint<E extends Exception> {
|
|||
case Initial:
|
||||
case NoResponse:
|
||||
case RequestSent:
|
||||
throw new NoResponseException();
|
||||
throw new NoResponseException(connection);
|
||||
default:
|
||||
// Do nothing
|
||||
break;
|
||||
|
|
|
@ -48,9 +48,9 @@ import org.jivesoftware.smackx.si.packet.StreamInitiation;
|
|||
*/
|
||||
public class FaultTolerantNegotiator extends StreamNegotiator {
|
||||
|
||||
private StreamNegotiator primaryNegotiator;
|
||||
private StreamNegotiator secondaryNegotiator;
|
||||
private XMPPConnection connection;
|
||||
private final StreamNegotiator primaryNegotiator;
|
||||
private final StreamNegotiator secondaryNegotiator;
|
||||
private final XMPPConnection connection;
|
||||
private PacketFilter primaryFilter;
|
||||
private PacketFilter secondaryFilter;
|
||||
|
||||
|
@ -178,7 +178,7 @@ public class FaultTolerantNegotiator extends StreamNegotiator {
|
|||
public InputStream call() throws XMPPErrorException, InterruptedException, SmackException {
|
||||
Packet streamInitiation = collector.nextResult();
|
||||
if (streamInitiation == null) {
|
||||
throw new NoResponseException();
|
||||
throw new NoResponseException(connection);
|
||||
}
|
||||
StreamNegotiator negotiator = determineNegotiator(streamInitiation);
|
||||
return negotiator.negotiateIncomingStream(streamInitiation);
|
||||
|
|
Loading…
Reference in a new issue