CompletionStage instead of Future for Submission#cancel return type?

Lance Andersen lance.andersen at oracle.com
Sun Dec 3 20:41:06 UTC 2017


> On Dec 3, 2017, at 3:27 PM, Sebastien Deleuze <sdeleuze at pivotal.io> wrote:
> 
> I tend to think the CompletionStage return type clearly express the fact
> the the result could complete or not.
> Another option is to use some kind of convention for specifying the
> CompletionStage nature, like getAsyncResult() or getResultAsync(), but I
> don't find this very elegant and it duplicates an information we already
> have with the return type.
> 
> Could you please indicate me where I can find the latest Javadoc and source
> code, since the URLs I have [1] [2] are outdated?
> 
> [1]
> http://hg.openjdk.java.net/jdk10/sandbox/jdk/file/a31057bda7c5/src/java.sql/share/classes/java/sql2 <http://hg.openjdk.java.net/jdk10/sandbox/jdk/file/a31057bda7c5/src/java.sql/share/classes/java/sql2>

That is the old sandbox prior to the idk consolidation, the current URL is http://hg.openjdk.java.net/jdk/sandbox/file/b49fd5dbaab6/src/java.sql/share/classes/java/sql2

> [2] http://cr.openjdk.java.net/~lancea/apidoc/ <http://cr.openjdk.java.net/~lancea/apidoc/>

This is the current javadoc based on the sandbox above.

We have not updated this since prior to the US Thanksgiving Holiday.  I expect we will updated it again within the next week or so



> 
> On Mon, Nov 27, 2017 at 7:56 AM, Douglas Surber <douglas.surber at oracle.com>
> wrote:
> 
>> The return value of cancel was overlooked when I modified everything to
>> use CompletionStage. Thanks for pointing it out. It’s fixed now.
>> 
>> I agree about the name “getCompletionStage”; I’m not sure about it.
>> “getResult” is better in some ways but it seems to me to be over promising.
>> The method doesn’t get the result, it gets a CompletionStage which will be
>> completed with the result. I’d be happy to change the name, but I’m not
>> convinced that “getResult” is the right name.
>> 
>> Douglas
>> 
>> 
>> 
>>> On Nov 23, 2017, at 7:00 AM, Sebastien Deleuze <sdeleuze at pivotal.io>
>> wrote:
>>> 
>>> While reviewing ADBA API, I noticed that Submission#cancel returns Future
>>> [1], which in practice is mostly usable in a blocking way since get() is
>>> blocking, checking regularly isDone() is not convenient at all, and
>>> unlike CompletionStage it does not provide a way to register a complete
>>> callback.
>>> 
>>> Is there any specific reason why CompletionStage<Boolean> can't be used
>>> there as return type? In addition to providing a non-blocking API, that
>>> would be also more consistent.
>>> 
>>> I am also not sure about Submission#getCompletionStage method name. Maybe
>>> something like Submission#getResult would be more clear than just naming
>> it
>>> against the return type, especially if there are 2 methods returning
>>> CompletionStage
>>> like in my proposal.
>>> 
>>> Any thoughts?
>>> 
>>> [1]
>>> http://cr.openjdk.java.net/~lancea/apidoc/java/sql2/
>> Submission.html#cancel--
>> 
>> 

 <http://oracle.com/us/design/oracle-email-sig-198324.gif>
 <http://oracle.com/us/design/oracle-email-sig-198324.gif> <http://oracle.com/us/design/oracle-email-sig-198324.gif>
 <http://oracle.com/us/design/oracle-email-sig-198324.gif>Lance Andersen| Principal Member of Technical Staff | +1.781.442.2037
Oracle Java Engineering 
1 Network Drive 
Burlington, MA 01803
Lance.Andersen at oracle.com <mailto:Lance.Andersen at oracle.com>





More information about the jdbc-spec-discuss mailing list