code: void cancel(AsyncChannelFuture future, Exception reason) throws ClosedChannelException, IOException {
          if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
              Tr.entry(tc, "cancel");
          }
          if (!isOpen()) {
              if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                  Tr.debug(tc, "Cancel request on closed connection");
              }
              future.setCancelInProgress(0);
              throw new ClosedChannelException();
          }
  
          // Cannot cancel a completed call.
          if (future.isCompleted()) {
              if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                  Tr.debug(tc, "Cancel request on completed future");
              }
              future.setCancelInProgress(0);
              if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
                  Tr.exit(tc, "cancel");
              }
              return;
          }
  
          long callid;
          if (((AsyncFuture) future).isRead()) {
              callid = this.readIOCB.getCallIdentifier();
          } else {
              callid = this.writeIOCB.getCallIdentifier();
          }
  
          int rc = provider.cancel2(this.channelIdentifier, callid);
          if (rc == 0) {
              // Mark the future completed with an Exception
              if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                  Tr.debug(tc, "Cancel Successful, resetting CancelInProgress state to 0");
              }
              future.setCancelInProgress(0);
              future.completed(reason);
          } else {
              // could not cancel
              if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                  Tr.debug(tc, "Cancel could not be completed");
              }
              future.setCancelInProgress(0);
          }
  
          if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
              Tr.exit(tc, "cancel");
          }
      }
docs: Package private version of cancel, which takes an exception as an
  additional parameter. The exception is applied to the future on
  cancellation.
  
  @param future
  @param reason
  @throws ClosedChannelException
  @throws IOException