diff --git a/spring-core/src/main/java/org/springframework/util/concurrent/SettableListenableFuture.java b/spring-core/src/main/java/org/springframework/util/concurrent/SettableListenableFuture.java index 7b37673302..3b805a962e 100644 --- a/spring-core/src/main/java/org/springframework/util/concurrent/SettableListenableFuture.java +++ b/spring-core/src/main/java/org/springframework/util/concurrent/SettableListenableFuture.java @@ -71,7 +71,7 @@ public class SettableListenableFuture implements ListenableFuture { */ public boolean setException(Throwable exception) { Assert.notNull(exception, "'exception' must not be null"); - boolean success = this.settableTask.setValue(exception); + boolean success = this.settableTask.setException(exception); if (success) { this.listenableFuture.run(); } @@ -151,17 +151,25 @@ public class SettableListenableFuture implements ListenableFuture { private volatile boolean cancelled = false; - public boolean setValue(Object value) { + public boolean setValue(T value) { if (this.cancelled) { return false; } return this.value.compareAndSet(NO_VALUE, value); } + public boolean setException(Throwable exception) { + if (this.cancelled) { + return false; + } + return this.value.compareAndSet(NO_VALUE, exception); + } + public void setCancelled() { this.cancelled = true; } + @SuppressWarnings("unchecked") @Override public T call() throws Exception { if (value.get() instanceof Exception) {