Eliminate Submission

Douglas Surber douglas.surber at oracle.com
Mon Feb 4 20:56:59 UTC 2019

I've never been happy with Submission but it seemed necessary. After thinking about it off and on for a couple of years it occurred to me that CompletionStage does not declare cancel. So I propose that ADBA define a new interface that is an extension to CompletionStage and that declares cancel.

Implementing this shouldn't be hard. Extend CompletableFuture and add cancel() which would just do whatever is necessary to cancel the Operation. I don't think any interaction with the CompletableFuture itself would be necessary.

Every use of Submission is the same or simpler with CancelableCompletionStage.

op.submit();							no change
CompletionStage cs = op.submit().getCompletionStage();		remove call to getCompletionStage();
CompleteableFuture cf = op.submit()
				.toCompleteableFuture();	remove call to getCompletionStage();
Submission s = op.submit();					replace Submission with CancelableCompletionStage

If you can see any problems with this let me know.


package jdk.incubator.sql2;

 * The result of submitting an {@link Operation}. This extension to
 * java.util.concurrent.CompletionStage adds a method {@code cancel}. Calling
 * this method attempts to prevent or abort execution of the Operation that
 * created this CancelableCompletionStage. This is in contrast to the {@code cancel(boolean)}
 * method declared by java.util.concurrent.CompletableFuture which does not
 * attempt to cancel the task that produces its result. As the signatures are
 * different the two methods do not interfere with one another.
 * @param <T> The type of the result of the {@link Operation} that created this
 * {@code CancelableCompletionStage}
public interface CancelableCompletionStage<T> extends java.util.concurrent.CompletionStage {

   * Request that the {@link Operation} not be executed or that its execution be
   * aborted if already begun. This is a best effort action and may not succeed
   * in preventing or aborting the execution. This method does not block.
   * If execution is prevented the Operation is completed exceptionally with
   * SkippedSqlException. If the Operation is aborted it is completed
   * exceptionally with SqlException.
   * @return a {@link java.util.concurrent.CompletionStage} that has the value
   * true if the {@link Operation} is canceled.
  public CompletionStage<Boolean> cancel();


More information about the jdbc-spec-discuss mailing list