diff --git a/mailbox-core/src/main/java/org/briarproject/mailbox/core/system/TaskScheduler.java b/mailbox-core/src/main/java/org/briarproject/mailbox/core/system/TaskScheduler.java index 83972016ece1d036c57b713917762ea04a2af60d..91729ed053df43f1c5fc6d1e4d70d0955a56e903 100644 --- a/mailbox-core/src/main/java/org/briarproject/mailbox/core/system/TaskScheduler.java +++ b/mailbox-core/src/main/java/org/briarproject/mailbox/core/system/TaskScheduler.java @@ -8,33 +8,33 @@ import java.util.concurrent.TimeUnit; */ public interface TaskScheduler { - /** - * Submits the given task to the given executor after the given delay. - * <p> - * If the platform supports wake locks, a wake lock will be held while - * submitting and running the task. - */ - Cancellable schedule(Runnable task, Executor executor, long delay, - TimeUnit unit); + /** + * Submits the given task to the given executor after the given delay. + * <p> + * If the platform supports wake locks, a wake lock will be held while + * submitting and running the task. + */ + Cancellable schedule(Runnable task, Executor executor, long delay, + TimeUnit unit); - /** - * Submits the given task to the given executor after the given delay, - * and then repeatedly with the given interval between executions - * (measured from the end of one execution to the beginning of the next). - * <p> - * If the platform supports wake locks, a wake lock will be held while - * submitting and running the task. - */ - Cancellable scheduleWithFixedDelay(Runnable task, Executor executor, - long delay, long interval, TimeUnit unit); + /** + * Submits the given task to the given executor after the given delay, + * and then repeatedly with the given interval between executions + * (measured from the end of one execution to the beginning of the next). + * <p> + * If the platform supports wake locks, a wake lock will be held while + * submitting and running the task. + */ + Cancellable scheduleWithFixedDelay(Runnable task, Executor executor, + long delay, long interval, TimeUnit unit); - interface Cancellable { + interface Cancellable { - /** - * Cancels the task if it has not already started running. If the task - * is {@link #scheduleWithFixedDelay(Runnable, Executor, long, long, TimeUnit) periodic}, - * all future executions of the task are cancelled. - */ - void cancel(); - } + /** + * Cancels the task if it has not already started running. If the task + * is {@link #scheduleWithFixedDelay(Runnable, Executor, long, long, TimeUnit) periodic}, + * all future executions of the task are cancelled. + */ + void cancel(); + } } diff --git a/mailbox-core/src/main/java/org/briarproject/mailbox/core/system/TaskSchedulerImpl.java b/mailbox-core/src/main/java/org/briarproject/mailbox/core/system/TaskSchedulerImpl.java index 80117a82d265d396f76b300ec8ff40a6c99c52df..aaa5b6f390840d54adbb8897695ae96edf6b7e5a 100644 --- a/mailbox-core/src/main/java/org/briarproject/mailbox/core/system/TaskSchedulerImpl.java +++ b/mailbox-core/src/main/java/org/briarproject/mailbox/core/system/TaskSchedulerImpl.java @@ -13,27 +13,27 @@ import javax.annotation.concurrent.ThreadSafe; @ThreadSafe class TaskSchedulerImpl implements TaskScheduler { - private final ScheduledExecutorService scheduledExecutorService; + private final ScheduledExecutorService scheduledExecutorService; - TaskSchedulerImpl(ScheduledExecutorService scheduledExecutorService) { - this.scheduledExecutorService = scheduledExecutorService; - } + TaskSchedulerImpl(ScheduledExecutorService scheduledExecutorService) { + this.scheduledExecutorService = scheduledExecutorService; + } - @Override - public Cancellable schedule(Runnable task, Executor executor, long delay, - TimeUnit unit) { - Runnable execute = () -> executor.execute(task); - ScheduledFuture<?> future = - scheduledExecutorService.schedule(execute, delay, unit); - return () -> future.cancel(false); - } + @Override + public Cancellable schedule(Runnable task, Executor executor, long delay, + TimeUnit unit) { + Runnable execute = () -> executor.execute(task); + ScheduledFuture<?> future = + scheduledExecutorService.schedule(execute, delay, unit); + return () -> future.cancel(false); + } - @Override - public Cancellable scheduleWithFixedDelay(Runnable task, Executor executor, - long delay, long interval, TimeUnit unit) { - Runnable execute = () -> executor.execute(task); - ScheduledFuture<?> future = scheduledExecutorService. - scheduleWithFixedDelay(execute, delay, interval, unit); - return () -> future.cancel(false); - } + @Override + public Cancellable scheduleWithFixedDelay(Runnable task, Executor executor, + long delay, long interval, TimeUnit unit) { + Runnable execute = () -> executor.execute(task); + ScheduledFuture<?> future = scheduledExecutorService. + scheduleWithFixedDelay(execute, delay, interval, unit); + return () -> future.cancel(false); + } } diff --git a/mailbox-core/src/main/java/org/briarproject/mailbox/core/tor/NetworkStatusEvent.java b/mailbox-core/src/main/java/org/briarproject/mailbox/core/tor/NetworkStatusEvent.java index db9366a553263a5551ebc56bab4dc4eaa20ea3b6..9d722cf39f8cbfea9ef888994432b047f995a6c2 100644 --- a/mailbox-core/src/main/java/org/briarproject/mailbox/core/tor/NetworkStatusEvent.java +++ b/mailbox-core/src/main/java/org/briarproject/mailbox/core/tor/NetworkStatusEvent.java @@ -7,13 +7,13 @@ import javax.annotation.concurrent.Immutable; @Immutable public class NetworkStatusEvent extends Event { - private final NetworkStatus status; + private final NetworkStatus status; - public NetworkStatusEvent(NetworkStatus status) { - this.status = status; - } + public NetworkStatusEvent(NetworkStatus status) { + this.status = status; + } - public NetworkStatus getStatus() { - return status; - } -} \ No newline at end of file + public NetworkStatus getStatus() { + return status; + } +} diff --git a/mailbox-core/src/main/java/org/briarproject/mailbox/core/util/NetworkUtils.java b/mailbox-core/src/main/java/org/briarproject/mailbox/core/util/NetworkUtils.java index 88b9306e8d692d0b5721832d6ff719da4f3649e6..d7029007c9bce376cbbcd3415b8d802ed4d9900a 100644 --- a/mailbox-core/src/main/java/org/briarproject/mailbox/core/util/NetworkUtils.java +++ b/mailbox-core/src/main/java/org/briarproject/mailbox/core/util/NetworkUtils.java @@ -14,18 +14,18 @@ import static org.slf4j.LoggerFactory.getLogger; public class NetworkUtils { - private static final Logger LOG = getLogger(NetworkUtils.class.getName()); + private static final Logger LOG = getLogger(NetworkUtils.class.getName()); - public static List<NetworkInterface> getNetworkInterfaces() { - try { - Enumeration<NetworkInterface> ifaces = - NetworkInterface.getNetworkInterfaces(); - // Despite what the docs say, the return value can be null - //noinspection ConstantConditions - return ifaces == null ? emptyList() : list(ifaces); - } catch (SocketException e) { - logException(LOG, e); - return emptyList(); - } - } + public static List<NetworkInterface> getNetworkInterfaces() { + try { + Enumeration<NetworkInterface> ifaces = + NetworkInterface.getNetworkInterfaces(); + // Despite what the docs say, the return value can be null + //noinspection ConstantConditions + return ifaces == null ? emptyList() : list(ifaces); + } catch (SocketException e) { + logException(LOG, e); + return emptyList(); + } + } }