diff --git a/src/main/java/org/cryptomator/common/CatchingExecutors.java b/src/main/java/org/cryptomator/common/CatchingExecutors.java index d212b2c31..e3dedca87 100644 --- a/src/main/java/org/cryptomator/common/CatchingExecutors.java +++ b/src/main/java/org/cryptomator/common/CatchingExecutors.java @@ -10,6 +10,7 @@ import java.util.concurrent.BlockingQueue; import java.util.concurrent.CancellationException; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; +import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; @@ -28,6 +29,18 @@ public final class CatchingExecutors { super(corePoolSize, threadFactory); } + @Override + public ScheduledFuture scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) { + Runnable oneShot = () -> this.execute(command); + return super.scheduleAtFixedRate(oneShot, initialDelay, period, unit); + } + + @Override + public ScheduledFuture scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) { + Runnable oneShot = () -> this.execute(command); + return super.scheduleWithFixedDelay(oneShot, initialDelay, delay, unit); + } + @Override protected void afterExecute(Runnable runnable, Throwable throwable) { super.afterExecute(runnable, throwable); @@ -77,6 +90,12 @@ public final class CatchingExecutors { } private static void afterExecuteFuture(Future future) { + if (future instanceof ScheduledFuture && !future.isDone()) { + //we assume that this must be a repeated ScheduledFutureTask, where the done-status is only set when not executed anymore + //see also https://github.com/cryptomator/cryptomator/pull/2422 + return; + } + try { future.get(); } catch (CancellationException ce) { diff --git a/src/main/java/org/cryptomator/common/vaults/AutoLocker.java b/src/main/java/org/cryptomator/common/vaults/AutoLocker.java index da584086d..d113f4177 100644 --- a/src/main/java/org/cryptomator/common/vaults/AutoLocker.java +++ b/src/main/java/org/cryptomator/common/vaults/AutoLocker.java @@ -46,7 +46,6 @@ public class AutoLocker { private boolean exceedsIdleTime(Vault vault) { assert vault.isUnlocked(); - // TODO: shouldn't we read these properties from within FX Application Thread? if (vault.getVaultSettings().autoLockWhenIdle().get()) { int maxIdleSeconds = vault.getVaultSettings().autoLockIdleSeconds().get(); var deadline = vault.getStats().getLastActivity().plusSeconds(maxIdleSeconds);