1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-09 17:19:39 +02:00

Rename "PacketReplyTimeout" → "ReplyTimeout"

This commit is contained in:
Florian Schmaus 2017-01-12 20:57:19 +01:00
parent b5415fe841
commit 7c46f58c80
21 changed files with 88 additions and 32 deletions

View file

@ -169,9 +169,9 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
protected String streamId;
/**
*
* The timeout to wait for a reply in milliseconds.
*/
private long packetReplyTimeout = SmackConfiguration.getDefaultPacketReplyTimeout();
private long replyTimeout = SmackConfiguration.getDefaultReplyTimeout();
/**
* The SmackDebugger allows to log and debug XML traffic.
@ -969,14 +969,26 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
}
}
@SuppressWarnings("deprecation")
@Override
public long getPacketReplyTimeout() {
return packetReplyTimeout;
return getReplyTimeout();
}
@SuppressWarnings("deprecation")
@Override
public void setPacketReplyTimeout(long timeout) {
setReplyTimeout(timeout);
}
@Override
public void setPacketReplyTimeout(long timeout) {
packetReplyTimeout = timeout;
public long getReplyTimeout() {
return replyTimeout;
}
@Override
public void setReplyTimeout(long timeout) {
replyTimeout = timeout;
}
private static boolean replyToUnknownIqDefault = true;
@ -1466,7 +1478,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
StanzaListener callback, ExceptionCallback exceptionCallback)
throws NotConnectedException, InterruptedException {
sendStanzaWithResponseCallback(stanza, replyFilter, callback, exceptionCallback,
getPacketReplyTimeout());
getReplyTimeout());
}
@Override
@ -1527,7 +1539,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
@Override
public void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback,
ExceptionCallback exceptionCallback) throws NotConnectedException, InterruptedException {
sendIqWithResponseCallback(iqRequest, callback, exceptionCallback, getPacketReplyTimeout());
sendIqWithResponseCallback(iqRequest, callback, exceptionCallback, getReplyTimeout());
}
@Override
@ -1556,7 +1568,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
public void run() {
removeSyncStanzaListener(packetListener);
}
}, getPacketReplyTimeout(), TimeUnit.MILLISECONDS);
}, getReplyTimeout(), TimeUnit.MILLISECONDS);
}
@Override

View file

@ -200,7 +200,7 @@ public final class SASLAuthentication {
else {
currentMechanism.authenticate(username, host, xmppServiceDomain, password, authzid, sslSession);
}
final long deadline = System.currentTimeMillis() + connection.getPacketReplyTimeout();
final long deadline = System.currentTimeMillis() + connection.getReplyTimeout();
while (!authenticationSuccessful && saslException == null) {
final long now = System.currentTimeMillis();
if (now >= deadline) break;

View file

@ -101,8 +101,32 @@ public final class SmackConfiguration {
* the server. The default value is 5000 ms.
*
* @return the milliseconds to wait for a response from the server
* @deprecated use {@link #getDefaultReplyTimeout()} instead.
*/
@Deprecated
public static int getDefaultPacketReplyTimeout() {
return getDefaultReplyTimeout();
}
/**
* Sets the number of milliseconds to wait for a response from
* the server.
*
* @param timeout the milliseconds to wait for a response from the server
* @deprecated use {@link #setDefaultReplyTimeout(int)} instead.
*/
@Deprecated
public static void setDefaultPacketReplyTimeout(int timeout) {
setDefaultReplyTimeout(timeout);
}
/**
* Returns the number of milliseconds to wait for a response from
* the server. The default value is 5000 ms.
*
* @return the milliseconds to wait for a response from the server
*/
public static int getDefaultReplyTimeout() {
// The timeout value must be greater than 0 otherwise we will answer the default value
if (defaultPacketReplyTimeout <= 0) {
defaultPacketReplyTimeout = 5000;
@ -116,7 +140,7 @@ public final class SmackConfiguration {
*
* @param timeout the milliseconds to wait for a response from the server
*/
public static void setDefaultPacketReplyTimeout(int timeout) {
public static void setDefaultReplyTimeout(int timeout) {
if (timeout <= 0) {
throw new IllegalArgumentException();
}

View file

@ -58,7 +58,7 @@ public class SmackException extends Exception {
/**
* Exception thrown always when there was no response to an request within the stanza(/packet) reply timeout of the used
* connection instance. You can modify (e.g. increase) the stanza(/packet) reply timeout with
* {@link XMPPConnection#setPacketReplyTimeout(long)}.
* {@link XMPPConnection#setReplyTimeout(long)}.
*/
public static final class NoResponseException extends SmackException {
/**
@ -111,7 +111,7 @@ public class SmackException extends Exception {
}
private static StringBuilder getWaitingFor(XMPPConnection connection) {
final long replyTimeout = connection.getPacketReplyTimeout();
final long replyTimeout = connection.getReplyTimeout();
final StringBuilder sb = new StringBuilder(256);
sb.append("No response received within reply timeout. Timeout was "
+ replyTimeout + "ms (~"

View file

@ -161,7 +161,7 @@ public class StanzaCollector {
* @throws InterruptedException
*/
public <P extends Stanza> P nextResult() throws InterruptedException {
return nextResult(connection.getPacketReplyTimeout());
return nextResult(connection.getReplyTimeout());
}
private volatile long waitStart;
@ -205,7 +205,7 @@ public class StanzaCollector {
*/
public <P extends Stanza> P nextResultOrThrow() throws NoResponseException, XMPPErrorException,
InterruptedException, NotConnectedException {
return nextResultOrThrow(connection.getPacketReplyTimeout());
return nextResultOrThrow(connection.getReplyTimeout());
}
/**

View file

@ -234,7 +234,7 @@ public class SynchronizationPoint<E extends Exception> {
* @throws InterruptedException
*/
private void waitForConditionOrTimeout() throws InterruptedException {
long remainingWait = TimeUnit.MILLISECONDS.toNanos(connection.getPacketReplyTimeout());
long remainingWait = TimeUnit.MILLISECONDS.toNanos(connection.getReplyTimeout());
while (state == State.RequestSent || state == State.Initial) {
if (remainingWait <= 0) {
state = State.NoResponse;

View file

@ -407,7 +407,9 @@ public interface XMPPConnection {
* XMPPConnection instance.
*
* @return the stanza(/packet) reply timeout in milliseconds
* @deprecated use {@link #getReplyTimeout()} instead.
*/
@Deprecated
public long getPacketReplyTimeout();
/**
@ -415,9 +417,27 @@ public interface XMPPConnection {
* {@link NoResponseException} if no reply to a request was received within the timeout period.
*
* @param timeout the stanza(/packet) reply timeout in milliseconds
* @deprecated use {@link #setReplyTimeout(long)} instead.
*/
@Deprecated
public void setPacketReplyTimeout(long timeout);
/**
* Returns the current value of the reply timeout in milliseconds for request for this
* XMPPConnection instance.
*
* @return the reply timeout in milliseconds
*/
public long getReplyTimeout();
/**
* Set the stanza(/packet) reply timeout in milliseconds. In most cases, Smack will throw a
* {@link NoResponseException} if no reply to a request was received within the timeout period.
*
* @param timeout for a reply in milliseconds
*/
public void setReplyTimeout(long timeout);
/**
* Get the connection counter of this XMPPConnection instance. Those can be used as ID to
* identify the connection, but beware that the ID may not be unique if you create more then

View file

@ -28,7 +28,7 @@ public class SmackConfigurationTest {
@Test
public void testSmackConfiguration() {
try {
SmackConfiguration.getDefaultPacketReplyTimeout();
SmackConfiguration.getDefaultReplyTimeout();
} catch (Throwable t) {
fail("SmackConfiguration threw Throwable");
}
@ -40,7 +40,7 @@ public class SmackConfigurationTest {
@Ignore
@Test
public void smackConfigurationShouldNotCauseInitializationTest() {
SmackConfiguration.getDefaultPacketReplyTimeout();
SmackConfiguration.getDefaultReplyTimeout();
// Only a call to SmackConfiguration.getVersion() should cause Smack to become initialized.
assertFalse(SmackConfiguration.isSmackInitialized());