Fix a bug where DefaultPromise.setUncancellable() returns a wrong value

- Fixes #2220
- Its Javadoc says it returns true when the promise is done (but not cancelled) or the promise is uncancellable, but it returns false when the promise is done.
This commit is contained in:
Trustin Lee 2014-02-10 11:39:29 -08:00
parent 084db044cd
commit 7e0e4c6325

View File

@ -461,14 +461,14 @@ public class DefaultPromise<V> extends AbstractFuture<V> implements Promise<V> {
public boolean setUncancellable() { public boolean setUncancellable() {
Object result = this.result; Object result = this.result;
if (isDone0(result)) { if (isDone0(result)) {
return false; return isCancelled0(result);
} }
synchronized (this) { synchronized (this) {
// Allow only once. // Allow only once.
result = this.result; result = this.result;
if (isDone0(result)) { if (isDone0(result)) {
return false; return isCancelled0(result);
} }
this.result = UNCANCELLABLE; this.result = UNCANCELLABLE;