1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-21 22:02:06 +01:00

Show correct reply timeout value in StanzaCollector's NoResponseException

This commit is contained in:
Florian Schmaus 2019-03-05 08:21:59 +01:00
parent 7f0932a481
commit 3d1a781a22
2 changed files with 17 additions and 3 deletions

View file

@ -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 (~"

View file

@ -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);