Question: I'd like to subclass [CompletableFuture](http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html) to override the default `Executor`. That is, if a user invokes a method without specifying an `Executor`, I want my own `Executor` to get used instead of the one normally used by `CompletableFuture`.

The Javadoc hints at the possibility of subclassing:

> 
> All CompletionStage methods are implemented independently of other public methods, so the behavior of one method is not impacted by overrides of others in subclasses.
> 
> 
> 

How am I supposed to implement static methods like `CompletableFuture.supplyAsync()` in the subclass if the underlying implementation depends on methods like `internalComplete()` which is package-private?

**How is one supposed to subclass CompletableFuture?**

---

What I'm trying to do...
------------------------

My user code needs to execute multiple tasks asynchronously using the same executor. For example: `CompletableFuture.supplyAsync(..., executor).thenApplyAsync(..., executor).thenApplyAsync(..., executor)`. I'd like the custom `CompletableFuture` implementation to use the first executor throughout all follow-up calls.

Answer: 
Answering the original question -- **How is one supposed to subclass CompletableFuture?**

Probably starting from a clean-room CompletionStage interface implementation (rather than from the concrete CompletableFuture class) a is a better option. Please take a look here:

<https://github.com/lukas-krecan/completion-stage>
Your goal is to limit the rate of access to the web service. Your solution is to use special executor which introduces delays. This is not the best solution, because some function in the chain can spend some time for other activity, or just wait too long in the queue to processor on O/S level and thus need not be delayed before accessing the web service, but will be delayed by the executor anyway. Delays should be embedded in the module which actually performs requests to the web service. It should remember the time of the previous request and, if it is too small, just call Thread.sleep() before sending request via socket. This way you need not any CompletableFuture and can call functions directly like f3(f1(f0))). At least it is more readable.