mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 03:52:06 +01:00
Show correct reply timeout value in StanzaCollector's NoResponseException
This commit is contained in:
parent
7f0932a481
commit
3d1a781a22
2 changed files with 17 additions and 3 deletions
|
@ -93,13 +93,24 @@ public class SmackException extends Exception {
|
|||
return new NoResponseException(sb.toString());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
// TODO: Remove in Smack 4.4.
|
||||
public static NoResponseException newWith(XMPPConnection connection,
|
||||
StanzaCollector collector) {
|
||||
return newWith(connection, collector.getStanzaFilter());
|
||||
}
|
||||
|
||||
public static NoResponseException newWith(long timeout,
|
||||
StanzaCollector collector) {
|
||||
return newWith(timeout, collector.getStanzaFilter());
|
||||
}
|
||||
|
||||
public static NoResponseException newWith(XMPPConnection connection, StanzaFilter filter) {
|
||||
final StringBuilder sb = getWaitingFor(connection);
|
||||
return newWith(connection.getReplyTimeout(), filter);
|
||||
}
|
||||
|
||||
public static NoResponseException newWith(long timeout, StanzaFilter filter) {
|
||||
final StringBuilder sb = getWaitingFor(timeout);
|
||||
sb.append(" Waited for response using: ");
|
||||
if (filter != null) {
|
||||
sb.append(filter.toString());
|
||||
|
@ -112,7 +123,10 @@ public class SmackException extends Exception {
|
|||
}
|
||||
|
||||
private static StringBuilder getWaitingFor(XMPPConnection connection) {
|
||||
final long replyTimeout = connection.getReplyTimeout();
|
||||
return getWaitingFor(connection.getReplyTimeout());
|
||||
}
|
||||
|
||||
private static StringBuilder getWaitingFor(final long replyTimeout) {
|
||||
final StringBuilder sb = new StringBuilder(256);
|
||||
sb.append("No response received within reply timeout. Timeout was "
|
||||
+ replyTimeout + "ms (~"
|
||||
|
|
|
@ -262,7 +262,7 @@ public class StanzaCollector {
|
|||
if (!connection.isConnected()) {
|
||||
throw new NotConnectedException(connection, packetFilter);
|
||||
}
|
||||
throw NoResponseException.newWith(connection, this);
|
||||
throw NoResponseException.newWith(timeout, this);
|
||||
}
|
||||
|
||||
XMPPErrorException.ifHasErrorThenThrow(result);
|
||||
|
|
Loading…
Reference in a new issue