1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-25 15:52:06 +01:00

Make XMPPConnection.schedule() protected

This method was never intended to be part of the public API. It's also
critical that the given Runnables complete within a reasonable
time frame so that they don't block following ones.
This commit is contained in:
Florian Schmaus 2014-05-21 21:43:16 +02:00
parent 1302dbe9cb
commit a19181ce04
3 changed files with 8 additions and 2 deletions

View file

@ -17,6 +17,8 @@
package org.jivesoftware.smack;
import java.lang.ref.WeakReference;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
public abstract class Manager {
@ -29,4 +31,8 @@ public abstract class Manager {
protected final XMPPConnection connection() {
return weakConnection.get();
}
protected ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
return connection().schedule(command, delay, unit);
}
}

View file

@ -1275,7 +1275,7 @@ public abstract class XMPPConnection {
}
}
public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
protected ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
return executorService.schedule(command, delay, unit);
}

View file

@ -308,7 +308,7 @@ public class PingManager extends Manager {
int nextPingIn = pingInterval - delta;
LOGGER.fine("Scheduling ServerPingTask in " + nextPingIn + " seconds (pingInterval="
+ pingInterval + ", delta=" + delta + ")");
nextAutomaticPing = connection().schedule(pingServerRunnable, pingInterval, TimeUnit.SECONDS);
nextAutomaticPing = schedule(pingServerRunnable, pingInterval, TimeUnit.SECONDS);
}
}