This release changes the asynchronous task API and improves cancellation handling.
Breaking changes
AsyncFun<T> now receives a single public Continuation<? super T> and returns void.
Task.fromAsync(continuation -> {
Executor executor = continuation.getExecutor();
continuation.invokeOnCancellation(() -> {
// Cleanup
});
executor.execute(() -> continuation.onSuccess("done"));
});Previously, asynchronous functions received an Executor and CompletionCallback, then returned a Cancellable.
Continuation now:
- Extends
CompletionCallback - Provides the task's
ExecutorthroughgetExecutor() - Registers cancellation cleanup through
invokeOnCancellation() - Separates cancellation cleanup from
onCancellation(), which signals task completion
This change is source and binary incompatible.
Other changes
- Improved cancellation race handling for asynchronous tasks, blocking I/O, futures, and Kotlin coroutines.
- Corrected JSpecify annotations and nullable generic bounds.
- Added NullAway and Error Prone checks for Java sources.
- Updated Kotlin to
2.4.10and kotlinx-coroutines to1.11.0. - Expanded cancellation and cancellable-future test coverage.
- Updated publishing and dependency automation.
Full changelog: v0.4.1...v0.5.0