On Sun, Apr 10, 2016 at 10:19 PM, Andrej Golovnin <andrej.golov...@gmail.com> wrote: >> On Sun, Apr 10, 2016 at 2:00 PM, Andrej Golovnin >> <andrej.golov...@gmail.com> wrote: >>> BTW, someone should describe in the JavaDocs of >>> CompletableFuture#orTimeout() >>> what would happen when this method is called multiple times on the same >>> CompletableFuture with different arguments. >> >> Hmmm the javadoc seems clear enough to me. CF can only be completed >> once. First to complete wins. > > What is the first: the first call to #orTimeout() or the call with the > lowest timeout? > > CompletableFuture cf = ... > cf.onTimeout(10L, TimeUnit.MINUTES); // 1. call > cf.onTimeout(10L, TimeUnit.SECONDS); // 2. call > cf.onTimeout(10L, TimeUnit.HOURS); // 3. call > > As far as I understand the implementation, the second call wins.
Yes. > What I miss from the JavaDocs is following: > It is allowed to call the #onTimeout()-methods multiple times. But it does > not mean that subsequent calls would override already defined timeout and > that the lowest timeout wins. It would be surprising if it did not work that way; this seems to follow from the current spec. I don't think it's worth adding this particular clarification to the spec (everything has a cost!)