Upgrading org.jetbrains.kotlinx:kotlinx-coroutines-core 0.30 to 1
Breaking0.30.2-eap13 → 1.11.0Breaking43Platform3Deprecated27New127Changed203Fixed168Other36
BreakingUpgrade verdict
40 breaking changes and 3 platform requirement changes.
In plain terms
- Removes support for the old Kotlin/Native memory model.
- Artificial stackframes in stacktrace recovery no longer contain the \b symbol and are now navigable in the IDE with proper documentation.
- Exceptions from the future builder during cancellation races are no longer sent to the global handler.
- If a Main dispatcher exists, delay and withTimeout use its clock by default.
Must act Top 5 of 70 that need code or config changes
Adds org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm 1.11.0.
Drops org.jetbrains.kotlin:kotlin-stdlib, org.jetbrains.kotlinx:kotlinx-coroutines-core-common.
Installs 3 packages in all (was 4).
What you must change
Breaking40
Removes support for the old Kotlin/Native memory model.
Artificial stackframes in stacktrace recovery no longer contain the \b symbol and are now navigable in the IDE with proper documentation.
When racing with cancellation, the future builder no longer reports unhandled exceptions into the global CoroutineExceptionHandler.
futureCoroutineExceptionHandlerDispatchers.Main is now the default time source for delay and withTimeout when present.
Dispatchers.MaindelaywithTimeoutSource-breaking: extension collect no longer resolves with a non-in-place argument of a functional type.
collectMakes DisposableHandle a fun interface and removes the corresponding inline extension.
DisposableHandleFlowCollectorRemoves support for the deprecated CommonPool.
CommonPoolRemoves atomic cancellation in channels; all channel operations and corresponding Flow operators are now cancellable in a non-atomic way.
FlowFlow.singleOrNull is aligned with the standard library and no longer throws IllegalStateException on multiple values.
Flow.singleOrNullIllegalStateExceptionRemoves kotlinx-coroutines-core-common and kotlinx-coroutines-core-native artifacts in the new HMPP publication scheme.
kotlinx-coroutines-core-commonkotlinx-coroutines-core-nativeflow prohibits emissions from non-scoped coroutines by default and recommends channelFlow instead.flowchannelFlowFlow can no longer be implemented directly;
AbstractFlow is introduced for extension.FlowAbstractFlowReworks flowViaChannel so the block parameter is no longer suspending, provides a CoroutineScope receiver and allows a conflated channel.
flowViaChannelCoroutineScopeRenames the Flow purity property to context preservation and makes it more restrictive.
FlowMakes major improvements to cancellation machinery and exception delivery consistency, and completely removes cancel with a custom exception.
Moves Promise-related functions from JS and Wasm/JS to the new web target; on Wasm/JS only JsAny subtypes are now accepted.
PromiseJsAnyChanges handling of coroutine exceptions that cannot be propagated on JS and Wasm/JS to report them to the JS runtime instead of logging.
Adds new generic upper bounds to the reactive integration API as dictated by the language since 1.8.0.
Merges kotlinx-coroutines-core and kotlinx-coroutines-jdk8 artifacts into a single artifact.
kotlinx-coroutines-corekotlinx-coroutines-jdk8CoroutineContext.isActive now returns true for contexts without any job in them.
CoroutineContext.isActiveRemoves obsolete TestCoroutineContext, fixing the kotlinx-coroutines-test JPMS package split between core and test modules.
TestCoroutineContextMakes CoroutineDispatcher.releaseInterceptedContinuation a final method.
CoroutineDispatcher.releaseInterceptedContinuationMajor channels API rework deprecates offer, poll, and sendBlocking, removes internal receiveCatching and onReceiveCatching, and removes SendChannel.isFull.
offerpollsendBlockingreceiveCatchingonReceiveCatchingreceiveOrNullonReceiveOrNullSendChannel.isFullRenames internal class TimeSource to SchedulerTimeSource to prevent wildcard import issues.
TimeSourceSchedulerTimeSourceSharingStarted is now a fun interface.
SharingStartedWhen a CoroutineDispatcher throws RejectedExecutionException, the current Job is cancelled and its execution is scheduled to Dispatchers.IO.
CoroutineDispatcherRejectedExecutionExceptionJobDispatchers.IOCancellableContinuation.invokeOnCancellation is now invoked when the continuation is cancelled while its resume has been dispatched.
CancellableContinuation.invokeOnCancellationReplaces scanReduce with runningReduce to be consistent with the Kotlin standard library.
scanReducerunningReduceChanges Flow.onCompletion behaviour to align with invokeOnCompletion, passing CancellationException to its cause parameter.
Flow.onCompletioninvokeOnCompletionCancellationExceptionChanges suspendCancellableCoroutine so cancellation is established before invoking the passed block argument.
suspendCancellableCoroutineThrows NoSuchElementException instead of UnsupportedOperationException for empty Flow in reduce operator (#1659).
NoSuchElementExceptionUnsupportedOperationExceptionFlowreduceReactive integration builders become top-level functions and reject a Job in their context.
CoroutineScopeJobReworks the context preservation invariant (#1210).
Replaces flatMap, merge and concatenate with flattenConcat, flattenMerge, flatMapConcat and flatMapMerge.
flatMapmergeconcatenateflattenConcatflattenMergeflatMapConcatflatMapMergeResuming a CancellableContinuation that is already in its final state now throws IllegalStateException (#901).
CancellableContinuationRestricts the rxFlowable generic parameter with Any.
rxFlowableRemoves deprecated API or marks it as internal.
Moves AgentPremain to kotlinx.coroutines.debug.internal to avoid a split package.
kotlinx.coroutines.debug.AgentPremainkotlinx.coroutines.debug.internal.AgentPremainThe kotlinx-coroutines-test API is completely reworked to address consistency, structured concurrency and correctness issues.
Marks experimental and internal coroutine API with kotlin.experimental.Experimental, requiring explicit opt-in.
kotlin.experimental.Experimental@ExperimentalCoroutinesApi@InternalCoroutinesApiPlatform3
Kotlin/Native new memory model is supported in regular builds conditionally on kotlin.native.binary.memoryModel being enabled.
kotlin.native.binary.memoryModelJDK 1.6 is no longer required for building the project.
Adds watchosX64 target support for Kotlin/Native.
watchosX64Deprecations to plan for
Deprecated27
Deprecates using CoroutineDispatcher as the coroutine context key; use ContinuationInterceptor instead.
CoroutineDispatcherContinuationInterceptorAdvances the deprecation levels on kotlinx-coroutines-test APIs.
kotlinx-coroutines-testAdds lint functions that mark passing a Job to coroutine builders as deprecated.
JobAdvances the deprecation levels for BroadcastChannel-based API.
BroadcastChannelAdvances the deprecation levels for the old kotlinx-coroutines-test API.
kotlinx-coroutines-testDeprecates Job.cancelFutureOnCompletion.
Job.cancelFutureOnCompletionDeprecates Job.cancelFutureOnCompletion.
Job.cancelFutureOnCompletionDeprecates the configuration of quiescence timeouts, replaced by the runTest timeout parameter.
runTestDeprecates BroadcastChannel and all the corresponding API.
BroadcastChannelThe old kotlinx-coroutines-test API is deprecated for removal.
Mutex.onLock is deprecated for removal.
Mutex.onLockRaises the deprecation level of all previously deprecated signatures.
Deprecates an obsolete method on the internal Delay interface.
DelayMarks BroadcastChannel and ConflatedBroadcastChannel as ObsoleteCoroutinesApi in favor of SharedFlow and StateFlow.
BroadcastChannelConflatedBroadcastChannelObsoleteCoroutinesApiSharedFlowStateFlowDeprecates misleading awaitSingleOr* functions on the Publisher type.
awaitSingleOr*PublisherDeprecates MaybeSource.await in favor of awaitSingle and adds lint functions for Mono to prevent ambiguous Publisher usages.
MaybeSource.awaitawaitSingleMonoPublisherObsolete reactive API is deprecated.
Deprecation level for API deprecated in 1.3.0 is increased.
Deprecates combineLatest in favor of combine.
combineLatestcombineDeprecates switchMap and introduces flatMapLatest, mapLatest and transformLatest.
switchMapflatMapLatestmapLatesttransformLatestDeprecates delayEach and delayFlow.
delayEachdelayFlowDeprecates
flowWith and flowViaChannel.flowWithflowViaChannelDeprecates all channel operators prone to coroutine leaks in favor of
Flow.FlowDeprecates consumerEach for removal on Publisher, ObservableSource and MaybeSource, introducing the collect extension instead.
consumerEachcollectPublisherObservableSourceMaybeSourceDeprecates SendChannel.isFull and ReceiveChannel.isEmpty.
SendChannel.isFullReceiveChannel.isEmptyMarks ReceiveChannel.receiveOrNull as obsolete and deprecated.
ReceiveChannel.receiveOrNullDeprecates Job.cancel(cause) and ReceiveChannel.cancel(cause); cancel() now returns Unit.
Job.cancel(cause)ReceiveChannel.cancel(cause)cancel()