Armin Schrenk 2 年之前
父節點
當前提交
b4f95c465a

+ 19 - 0
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) {

+ 0 - 1
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);