From 437ce9bb0e096f0c19e7c2c24c35a9c2dd673802 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 25 Sep 2012 13:54:33 +0200 Subject: [PATCH] Calling cancel on a Future returned by a TaskScheduler works reliably now Issue: SPR-9821 --- .../scheduling/concurrent/ReschedulingRunnable.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/org.springframework.context/src/main/java/org/springframework/scheduling/concurrent/ReschedulingRunnable.java b/org.springframework.context/src/main/java/org/springframework/scheduling/concurrent/ReschedulingRunnable.java index 7fa05611f5..fba41f0778 100644 --- a/org.springframework.context/src/main/java/org/springframework/scheduling/concurrent/ReschedulingRunnable.java +++ b/org.springframework.context/src/main/java/org/springframework/scheduling/concurrent/ReschedulingRunnable.java @@ -108,21 +108,27 @@ class ReschedulingRunnable extends DelegatingErrorHandlingRunnable implements Sc } public Object get() throws InterruptedException, ExecutionException { + ScheduledFuture curr; synchronized (this.triggerContextMonitor) { - return this.currentFuture.get(); + curr = this.currentFuture; } + return curr.get(); } public Object get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { + ScheduledFuture curr; synchronized (this.triggerContextMonitor) { - return this.currentFuture.get(timeout, unit); + curr = this.currentFuture; } + return curr.get(timeout, unit); } public long getDelay(TimeUnit unit) { + ScheduledFuture curr; synchronized (this.triggerContextMonitor) { - return this.currentFuture.getDelay(unit); + curr = this.currentFuture; } + return curr.getDelay(unit); } public int compareTo(Delayed other) {