From bb4a9cca1bfa5d5e887b98ec13d4a9f553dace06 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 16 Jun 2014 17:06:52 -0400 Subject: [PATCH] Add suppress warning in SettableListenableFuture --- .../util/concurrent/SettableListenableFuture.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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) {