diff --git a/jdk/src/share/classes/sun/nio/ch/PendingFuture.java b/jdk/src/share/classes/sun/nio/ch/PendingFuture.java index 863b0f08d67..b2b3baceb62 100644 --- a/jdk/src/share/classes/sun/nio/ch/PendingFuture.java +++ b/jdk/src/share/classes/sun/nio/ch/PendingFuture.java @@ -35,8 +35,6 @@ import java.io.IOException; */ final class PendingFuture implements Future { - private static final CancellationException CANCELLED = - new CancellationException(); private final AsynchronousChannel channel; private final CompletionHandler handler; @@ -180,7 +178,7 @@ final class PendingFuture implements Future { latch.await(); } if (exc != null) { - if (exc == CANCELLED) + if (exc instanceof CancellationException) throw new CancellationException(); throw new ExecutionException(exc); } @@ -197,7 +195,7 @@ final class PendingFuture implements Future { if (!latch.await(timeout, unit)) throw new TimeoutException(); } if (exc != null) { - if (exc == CANCELLED) + if (exc instanceof CancellationException) throw new CancellationException(); throw new ExecutionException(exc); } @@ -205,7 +203,7 @@ final class PendingFuture implements Future { } Throwable exception() { - return (exc != CANCELLED) ? exc : null; + return (exc instanceof CancellationException) ? null : exc; } V value() { @@ -214,7 +212,7 @@ final class PendingFuture implements Future { @Override public boolean isCancelled() { - return (exc == CANCELLED); + return (exc instanceof CancellationException); } @Override @@ -233,7 +231,7 @@ final class PendingFuture implements Future { ((Cancellable)channel()).onCancel(this); // set result and cancel timer - exc = CANCELLED; + exc = new CancellationException(); haveResult = true; if (timeoutTask != null) timeoutTask.cancel(false);