mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-22 02:27:58 +01:00
Rename "PacketReplyTimeout" → "ReplyTimeout"
This commit is contained in:
parent
b5415fe841
commit
7c46f58c80
21 changed files with 88 additions and 32 deletions
|
@ -182,7 +182,7 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
|
|||
// Wait for the response from the server
|
||||
synchronized (this) {
|
||||
if (!connected) {
|
||||
final long deadline = System.currentTimeMillis() + getPacketReplyTimeout();
|
||||
final long deadline = System.currentTimeMillis() + getReplyTimeout();
|
||||
while (!notified) {
|
||||
final long now = System.currentTimeMillis();
|
||||
if (now >= deadline) break;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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 (~"
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -96,7 +96,7 @@ public abstract class StreamNegotiator {
|
|||
final String eventKey = initiation.getFrom().toString() + '\t' + initiation.getSessionID();
|
||||
IQ streamMethodInitiation;
|
||||
try {
|
||||
streamMethodInitiation = initationSetEvents.performActionAndWaitForEvent(eventKey, connection.getPacketReplyTimeout(), new Callback<NotConnectedException>() {
|
||||
streamMethodInitiation = initationSetEvents.performActionAndWaitForEvent(eventKey, connection.getReplyTimeout(), new Callback<NotConnectedException>() {
|
||||
@Override
|
||||
public void action() throws NotConnectedException {
|
||||
try {
|
||||
|
|
|
@ -355,7 +355,7 @@ public class MultiUserChat {
|
|||
* @since 4.2
|
||||
*/
|
||||
public MucEnterConfiguration.Builder getEnterConfigurationBuilder(Resourcepart nickname) {
|
||||
return new MucEnterConfiguration.Builder(nickname, connection.getPacketReplyTimeout());
|
||||
return new MucEnterConfiguration.Builder(nickname, connection.getReplyTimeout());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -186,7 +186,7 @@ public final class PingManager extends Manager {
|
|||
* @throws InterruptedException
|
||||
*/
|
||||
public boolean ping(Jid jid) throws NotConnectedException, NoResponseException, InterruptedException {
|
||||
return ping(jid, connection().getPacketReplyTimeout());
|
||||
return ping(jid, connection().getReplyTimeout());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -231,7 +231,7 @@ public final class PingManager extends Manager {
|
|||
* @throws InterruptedException
|
||||
*/
|
||||
public boolean pingMyServer(boolean notifyListeners) throws NotConnectedException, InterruptedException {
|
||||
return pingMyServer(notifyListeners, connection().getPacketReplyTimeout());
|
||||
return pingMyServer(notifyListeners, connection().getReplyTimeout());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -248,7 +248,7 @@ public class PingTest extends InitExtensions {
|
|||
*/
|
||||
private static DummyConnection getAuthenticatedDummyConnectionWithoutIqReplies() throws SmackException, IOException, XMPPException, InterruptedException {
|
||||
DummyConnection con = new DummyConnection();
|
||||
con.setPacketReplyTimeout(500);
|
||||
con.setReplyTimeout(500);
|
||||
con.connect();
|
||||
con.login();
|
||||
return con;
|
||||
|
|
|
@ -88,7 +88,7 @@ public class ConfigureFormTest
|
|||
|
||||
Node node = mgr.getNode("princely_musings");
|
||||
|
||||
SmackConfiguration.setDefaultPacketReplyTimeout(100);
|
||||
SmackConfiguration.setDefaultReplyTimeout(100);
|
||||
con.setTimeout();
|
||||
|
||||
node.getNodeConfiguration();
|
||||
|
|
|
@ -473,7 +473,7 @@ public final class Roster extends Manager {
|
|||
}
|
||||
|
||||
protected boolean waitUntilLoaded() throws InterruptedException {
|
||||
long waitTime = connection().getPacketReplyTimeout();
|
||||
long waitTime = connection().getReplyTimeout();
|
||||
long start = System.currentTimeMillis();
|
||||
while (!isLoaded()) {
|
||||
if (waitTime <= 0) {
|
||||
|
|
|
@ -75,7 +75,7 @@ public class RosterTest extends InitSmackIm {
|
|||
rosterListener = new TestRosterListener();
|
||||
roster = Roster.getInstanceFor(connection);
|
||||
roster.addRosterListener(rosterListener);
|
||||
connection.setPacketReplyTimeout(1000 * 60 * 5);
|
||||
connection.setReplyTimeout(1000 * 60 * 5);
|
||||
}
|
||||
|
||||
@After
|
||||
|
|
|
@ -61,7 +61,7 @@ public class SubscriptionPreApprovalTest extends InitSmackIm {
|
|||
rosterListener = new TestRosterListener();
|
||||
roster = Roster.getInstanceFor(connection);
|
||||
roster.addRosterListener(rosterListener);
|
||||
connection.setPacketReplyTimeout(1000 * 60 * 5);
|
||||
connection.setReplyTimeout(1000 * 60 * 5);
|
||||
}
|
||||
|
||||
@After
|
||||
|
|
|
@ -133,7 +133,7 @@ public class SmackIntegrationTestFramework {
|
|||
SmackConfiguration.DEBUG = true;
|
||||
}
|
||||
if (config.replyTimeout > 0) {
|
||||
SmackConfiguration.setDefaultPacketReplyTimeout(config.replyTimeout);
|
||||
SmackConfiguration.setDefaultReplyTimeout(config.replyTimeout);
|
||||
}
|
||||
if (config.securityMode != SecurityMode.required) {
|
||||
AccountManager.sensitiveOperationOverInsecureConnectionDefault(true);
|
||||
|
|
|
@ -104,7 +104,7 @@ public class RosterIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
try {
|
||||
rosterOne.createEntry(conTwo.getUser().asBareJid(), conTwosRosterName, null);
|
||||
|
||||
assertTrue(addedAndSubscribed.waitForResult(2 * connection.getPacketReplyTimeout()));
|
||||
assertTrue(addedAndSubscribed.waitForResult(2 * connection.getReplyTimeout()));
|
||||
}
|
||||
finally {
|
||||
rosterTwo.removeSubscribeListener(subscribeListener);
|
||||
|
|
|
@ -75,8 +75,8 @@ public class IoT {
|
|||
final XMPPTCPConnection dataThingConnection = new XMPPTCPConnection(dataThingConnectionConfiguration);
|
||||
final XMPPTCPConnection readingThingConnection = new XMPPTCPConnection(readingThingConnectionConfiguration);
|
||||
|
||||
dataThingConnection.setPacketReplyTimeout(TIMEOUT);
|
||||
readingThingConnection.setPacketReplyTimeout(TIMEOUT);
|
||||
dataThingConnection.setReplyTimeout(TIMEOUT);
|
||||
readingThingConnection.setReplyTimeout(TIMEOUT);
|
||||
|
||||
dataThingConnection.setUseStreamManagement(false);
|
||||
readingThingConnection.setUseStreamManagement(false);
|
||||
|
|
|
@ -89,7 +89,7 @@ public class TlsTest {
|
|||
|
||||
XMPPTCPConnection connection = new XMPPTCPConnection(builder.build());
|
||||
|
||||
connection.setPacketReplyTimeout(20000);
|
||||
connection.setReplyTimeout(20000);
|
||||
|
||||
try {
|
||||
connection.connect().login();
|
||||
|
|
Loading…
Reference in a new issue