Skip to content

New Promise API methods; Overriding default async executor; Optimizations + Bug fixes

Compare
Choose a tag to compare
@vsilaev vsilaev released this 27 Mar 08:56
· 247 commits to master since this release
3528948

Bug fixes

The release contains single but very important bug fix - DependentPromise interface now correctly overrides methods inherited from CompletionStage (with DependentPromise as a return type, previously it was Promise)

Optimizations

  • Avoid using of CompletableFuture wrappers inside internal code - use CompletableFuture class itself
  • Optimize edge-cases for Promises.any / anyStrict / atLeast / atLeastStrict
  • Refactor common code used internally into separate internal utility class to minimize inter-relations between classes.
  • Better wrapper for custom CompletionStage implementation that implements Future interface as well (i.e. prefer delegation wherever possible) -- see CompletionStageWrapper + BlockingCompletionStageAdapter
  • Custom Promise adapter for CompletionStage that adds blocking Future API (previously it was done via implicit creation of CompletableFuture) -- see CompletionStageWrapper

Enhancements and new API

The release adds an option to override default async Executor for Promise. Promise.defaultAsyncOn(Executor) + related adapters serves this purpose. Also, DependentPromise extend this behavior for own declared methods (the ones these let user enlist origins).
Additionally. Promise.join() method is added - technically, it's like a Promise.get() but without throwing checked exceptions.