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

- Fixes #2220 - again
- Missing negation
This commit is contained in:
Trustin Lee 2014-02-10 11:47:54 -08:00
parent 7e0e4c6325
commit 0e71da3082

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 isCancelled0(result); 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 isCancelled0(result); return !isCancelled0(result);
} }
this.result = UNCANCELLABLE; this.result = UNCANCELLABLE;