Skip to content

Commit b231887

Browse files
authored
Merge pull request #2812 from Kotlin/version-1.5.1
Version 1.5.1
2 parents b852b20 + 2a4c00b commit b231887

File tree

143 files changed

+1666
-1529
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+1666
-1529
lines changed

CHANGES.md

+18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# Change log for kotlinx.coroutines
22

3+
## Version 1.5.1
4+
5+
* Atomic `update`, `getAndUpdate`, and `updateAndGet` operations of `MutableStateFlow` (#2720).
6+
* `Executor.asCoroutineDispatcher` implementation improvements (#2601):
7+
* If the target executor is `ScheduledExecutorService`, then its `schedule` API is used for time-related coroutine operations.
8+
* `RemoveOnCancelPolicy` is now part of the public contract.
9+
* Introduced overloads for `Task.asDeferred` and `Task.await` that accept `CancellationTokenSource` for bidirectional cancellation (#2527).
10+
* Reactive streams are updated to `1.0.3` (#2740).
11+
* `CopyableThrowable` is allowed to modify the exception message during stacktrace recovery (#1931).
12+
* `CoroutineDispatcher.releaseInterceptedContinuation` is now a `final` method (#2785).
13+
* Closing a Handler underlying `Handler.asCoroutineDispatcher` now causes the dispatched coroutines to be canceled on `Dispatchers.IO (#2778)`.
14+
* Kotlin is updated to 1.5.20.
15+
* Fixed a spurious `ClassCastException` in `releaseInterceptedContinuation` and `IllegalStateException` from `tryReleaseClaimedContinuation` (#2736, #2768).
16+
* Fixed inconsistent exception message during stacktrace recovery for non-suspending channel iterators (#2749).
17+
* Fixed linear stack usage for `CompletableFuture.asDeferred` when the target future has a long chain of listeners (#2730).
18+
* Any exceptions from `CoroutineDispatcher.isDispatchNeeded` are now considered as fatal and are propagated to the caller (#2733).
19+
* Internal `DebugProbesKt` (used in the debugger implementation) are moved from `debug` to `core` module.
20+
321
## Version 1.5.0
422

523
Note that this is a full changelog relative to 1.4.3 version. Changelog relative to 1.5.0-RC can be found in the end.

README.md

+22-22
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
[![official JetBrains project](https://jb.gg/badges/official.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)
44
[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](https://www.apache.org/licenses/LICENSE-2.0)
5-
[![Download](https://img.shields.io/maven-central/v/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.5.0)](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.5.0/pom)
6-
[![Kotlin](https://img.shields.io/badge/kotlin-1.5.0-blue.svg?logo=kotlin)](http://kotlinlang.org)
5+
[![Download](https://img.shields.io/maven-central/v/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.5.1)](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.5.1/pom)
6+
[![Kotlin](https://img.shields.io/badge/kotlin-1.5.20-blue.svg?logo=kotlin)](http://kotlinlang.org)
77
[![Slack channel](https://img.shields.io/badge/chat-slack-green.svg?logo=slack)](https://kotlinlang.slack.com/messages/coroutines/)
88

99
Library support for Kotlin coroutines with [multiplatform](#multiplatform) support.
10-
This is a companion version for the Kotlin `1.5.0` release.
10+
This is a companion version for the Kotlin `1.5.20` release.
1111

1212
```kotlin
1313
suspend fun main() = coroutineScope {
@@ -35,7 +35,7 @@ suspend fun main() = coroutineScope {
3535
* [select] expression support and more.
3636
* [core/jvm](kotlinx-coroutines-core/jvm/) — additional core features available on Kotlin/JVM:
3737
* [Dispatchers.IO] dispatcher for blocking coroutines;
38-
* [Executor.asCoroutineDispatcher] extension, custom thread pools, and more.
38+
* [Executor.asCoroutineDispatcher][asCoroutineDispatcher] extension, custom thread pools, and more.
3939
* [core/js](kotlinx-coroutines-core/js/) — additional core features available on Kotlin/JS:
4040
* Integration with `Promise` via [Promise.await] and [promise] builder;
4141
* Integration with `Window` via [Window.asCoroutineDispatcher], etc.
@@ -83,15 +83,15 @@ Add dependencies (you can also add other modules that you need):
8383
<dependency>
8484
<groupId>org.jetbrains.kotlinx</groupId>
8585
<artifactId>kotlinx-coroutines-core</artifactId>
86-
<version>1.5.0</version>
86+
<version>1.5.1</version>
8787
</dependency>
8888
```
8989

9090
And make sure that you use the latest Kotlin version:
9191

9292
```xml
9393
<properties>
94-
<kotlin.version>1.5.0</kotlin.version>
94+
<kotlin.version>1.5.20</kotlin.version>
9595
</properties>
9696
```
9797

@@ -101,15 +101,15 @@ Add dependencies (you can also add other modules that you need):
101101

102102
```groovy
103103
dependencies {
104-
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0'
104+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1'
105105
}
106106
```
107107

108108
And make sure that you use the latest Kotlin version:
109109

110110
```groovy
111111
buildscript {
112-
ext.kotlin_version = '1.5.0'
112+
ext.kotlin_version = '1.5.20'
113113
}
114114
```
115115

@@ -127,15 +127,15 @@ Add dependencies (you can also add other modules that you need):
127127

128128
```groovy
129129
dependencies {
130-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0")
130+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1")
131131
}
132132
```
133133

134134
And make sure that you use the latest Kotlin version:
135135

136136
```groovy
137137
plugins {
138-
kotlin("jvm") version "1.5.0"
138+
kotlin("jvm") version "1.5.20"
139139
}
140140
```
141141

@@ -147,7 +147,7 @@ Add [`kotlinx-coroutines-android`](ui/kotlinx-coroutines-android)
147147
module as a dependency when using `kotlinx.coroutines` on Android:
148148

149149
```groovy
150-
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0'
150+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.1'
151151
```
152152

153153
This gives you access to the Android [Dispatchers.Main]
@@ -180,7 +180,7 @@ In common code that should get compiled for different platforms, you can add a d
180180
```groovy
181181
commonMain {
182182
dependencies {
183-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0")
183+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1")
184184
}
185185
}
186186
```
@@ -192,7 +192,7 @@ Platform-specific dependencies are recommended to be used only for non-multiplat
192192
#### JS
193193

194194
Kotlin/JS version of `kotlinx.coroutines` is published as
195-
[`kotlinx-coroutines-core-js`](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core-js/1.5.0/jar)
195+
[`kotlinx-coroutines-core-js`](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core-js/1.5.1/jar)
196196
(follow the link to get the dependency declaration snippet) and as [`kotlinx-coroutines-core`](https://www.npmjs.com/package/kotlinx-coroutines-core) NPM package.
197197

198198
#### Native
@@ -233,10 +233,10 @@ See [Contributing Guidelines](CONTRIBUTING.md).
233233
[SupervisorJob()]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-supervisor-job.html
234234
[CoroutineExceptionHandler]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-exception-handler/index.html
235235
[Dispatchers.IO]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-dispatchers/-i-o.html
236-
[Executor.asCoroutineDispatcher]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/java.util.concurrent.-executor/as-coroutine-dispatcher.html
237-
[Promise.await]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/kotlin.js.-promise/await.html
236+
[asCoroutineDispatcher]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/as-coroutine-dispatcher.html
237+
[Promise.await]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/await.html
238238
[promise]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/promise.html
239-
[Window.asCoroutineDispatcher]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/org.w3c.dom.-window/as-coroutine-dispatcher.html
239+
[Window.asCoroutineDispatcher]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/as-coroutine-dispatcher.html
240240

241241
<!--- INDEX kotlinx.coroutines.flow -->
242242

@@ -261,7 +261,7 @@ See [Contributing Guidelines](CONTRIBUTING.md).
261261
<!--- MODULE kotlinx-coroutines-test -->
262262
<!--- INDEX kotlinx.coroutines.test -->
263263

264-
[Dispatchers.setMain]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/kotlinx.coroutines.-dispatchers/set-main.html
264+
[Dispatchers.setMain]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/set-main.html
265265
[TestCoroutineScope]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/-test-coroutine-scope/index.html
266266

267267
<!--- MODULE kotlinx-coroutines-debug -->
@@ -281,23 +281,23 @@ See [Contributing Guidelines](CONTRIBUTING.md).
281281
<!--- MODULE kotlinx-coroutines-jdk8 -->
282282
<!--- INDEX kotlinx.coroutines.future -->
283283

284-
[CompletionStage.await]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-jdk8/kotlinx.coroutines.future/java.util.concurrent.-completion-stage/await.html
284+
[CompletionStage.await]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-jdk8/kotlinx.coroutines.future/await.html
285285

286286
<!--- MODULE kotlinx-coroutines-guava -->
287287
<!--- INDEX kotlinx.coroutines.guava -->
288288

289-
[ListenableFuture.await]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-guava/kotlinx.coroutines.guava/com.google.common.util.concurrent.-listenable-future/await.html
289+
[ListenableFuture.await]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-guava/kotlinx.coroutines.guava/await.html
290290

291291
<!--- MODULE kotlinx-coroutines-play-services -->
292292
<!--- INDEX kotlinx.coroutines.tasks -->
293293

294-
[Task.await]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-play-services/kotlinx.coroutines.tasks/com.google.android.gms.tasks.-task/await.html
294+
[Task.await]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-play-services/kotlinx.coroutines.tasks/await.html
295295

296296
<!--- MODULE kotlinx-coroutines-reactive -->
297297
<!--- INDEX kotlinx.coroutines.reactive -->
298298

299-
[Publisher.collect]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-reactive/kotlinx.coroutines.reactive/org.reactivestreams.-publisher/collect.html
300-
[Publisher.awaitSingle]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-reactive/kotlinx.coroutines.reactive/org.reactivestreams.-publisher/await-single.html
299+
[Publisher.collect]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-reactive/kotlinx.coroutines.reactive/collect.html
300+
[Publisher.awaitSingle]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-reactive/kotlinx.coroutines.reactive/await-single.html
301301
[kotlinx.coroutines.reactive.publish]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-reactive/kotlinx.coroutines.reactive/publish.html
302302

303303
<!--- MODULE kotlinx-coroutines-rx2 -->

build.gradle

+55-30
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
/*
22
* Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
4+
5+
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
46
import org.jetbrains.kotlin.konan.target.HostManager
57
import org.gradle.util.VersionNumber
8+
import org.jetbrains.dokka.gradle.DokkaTaskPartial
9+
import org.jetbrains.dokka.gradle.DokkaMultiModuleTask
610

711
apply plugin: 'jdk-convention'
8-
apply from: rootProject.file("gradle/experimental.gradle")
12+
apply from: rootProject.file("gradle/opt-in.gradle")
913

1014
def coreModule = "kotlinx-coroutines-core"
1115
// Not applicable for Kotlin plugin
12-
def sourceless = ['kotlinx.coroutines', 'site', 'kotlinx-coroutines-bom', 'integration-testing']
13-
def internal = ['kotlinx.coroutines', 'site', 'benchmarks', 'js-stub', 'stdlib-stubs', 'integration-testing']
16+
def sourceless = ['kotlinx.coroutines', 'kotlinx-coroutines-bom', 'integration-testing']
17+
def internal = ['kotlinx.coroutines', 'benchmarks', 'integration-testing']
1418
// Not published
1519
def unpublished = internal + ['example-frontend-js', 'android-unit-tests']
1620

@@ -32,17 +36,14 @@ buildscript {
3236
throw new IllegalArgumentException("'kotlin_snapshot_version' should be defined when building with snapshot compiler")
3337
}
3438
}
35-
// These three flags are enabled in train builds for JVM IR compiler testing
36-
ext.jvm_ir_enabled = rootProject.properties['enable_jvm_ir'] != null
37-
ext.jvm_ir_api_check_enabled = rootProject.properties['enable_jvm_ir_api_check'] != null
3839
ext.native_targets_enabled = rootProject.properties['disable_native_targets'] == null
3940

4041
// Determine if any project dependency is using a snapshot version
4142
ext.using_snapshot_version = build_snapshot_train
4243
rootProject.properties.each { key, value ->
4344
if (key.endsWith("_version") && value instanceof String && value.endsWith("-SNAPSHOT")) {
4445
println("NOTE: USING SNAPSHOT VERSION: $key=$value")
45-
ext.using_snapshot_version=true
46+
ext.using_snapshot_version = true
4647
}
4748
}
4849

@@ -53,11 +54,10 @@ buildscript {
5354
}
5455

5556
repositories {
56-
// Leftover until we migrated to Dokka 1.4.30
57-
maven { url "https://kotlin.bintray.com/kotlin-dev" }
58-
maven { url "https://jetbrains.bintray.com/kotlin-native-dependencies" }
57+
mavenCentral()
5958
maven { url "https://plugins.gradle.org/m2/" }
6059
maven { url "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" }
60+
mavenLocal()
6161
}
6262

6363
dependencies {
@@ -74,9 +74,6 @@ buildscript {
7474

7575
CacheRedirector.configureBuildScript(buildscript, rootProject)
7676
}
77-
78-
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
79-
8077
// todo:KLUDGE: Hierarchical project structures are not fully supported in IDEA, enable only for a regular built
8178
if (!Idea.active) {
8279
ext.set("kotlin.mpp.enableGranularSourceSetsMetadata", "true")
@@ -127,7 +124,6 @@ apply plugin: "binary-compatibility-validator"
127124
apiValidation {
128125
ignoredProjects += unpublished + ["kotlinx-coroutines-bom"]
129126
if (build_snapshot_train) {
130-
ignoredProjects.remove("site")
131127
ignoredProjects.remove("example-frontend-js")
132128
ignoredProjects.add("kotlinx-coroutines-core")
133129
}
@@ -166,9 +162,8 @@ configure(subprojects.findAll { !sourceless.contains(it.name) }) {
166162

167163
// Configure options for all Kotlin compilation tasks
168164
tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile).all {
169-
kotlinOptions.freeCompilerArgs += experimentalAnnotations.collect { "-Xuse-experimental=" + it }
165+
kotlinOptions.freeCompilerArgs += optInAnnotations.collect { "-Xopt-in=" + it }
170166
kotlinOptions.freeCompilerArgs += "-progressive"
171-
kotlinOptions.freeCompilerArgs += "-XXLanguage:+InlineClasses"
172167
// Disable KT-36770 for RxJava2 integration
173168
kotlinOptions.freeCompilerArgs += "-XXLanguage:-ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated"
174169
// Remove null assertions to get smaller bytecode on Android
@@ -227,23 +222,25 @@ configure(subprojects.findAll {
227222
}
228223

229224
def core_docs_url = "https://kotlin.github.io/kotlinx.coroutines/$coreModule/"
230-
def core_docs_file = "$projectDir/kotlinx-coroutines-core/build/dokka/kotlinx-coroutines-core/package-list"
225+
def core_docs_file = "$projectDir/kotlinx-coroutines-core/build/dokka/htmlPartial/package-list"
226+
apply plugin: "org.jetbrains.dokka"
231227

232228
configure(subprojects.findAll { !unpublished.contains(it.name) }) {
233229
if (it.name != 'kotlinx-coroutines-bom') {
234-
apply from: rootProject.file('gradle/dokka.gradle')
230+
apply from: rootProject.file('gradle/dokka.gradle.kts')
235231
}
236232
apply from: rootProject.file('gradle/publish.gradle')
237233
}
238234

239235
configure(subprojects.findAll { !unpublished.contains(it.name) }) {
240236
if (it.name != "kotlinx-coroutines-bom") {
241237
if (it.name != coreModule) {
242-
dokka.dependsOn project(":$coreModule").dokka
243-
tasks.withType(dokka.getClass()) {
244-
externalDocumentationLink {
245-
url = new URL(core_docs_url)
246-
packageListUrl = new File(core_docs_file).toURI().toURL()
238+
tasks.withType(DokkaTaskPartial.class) {
239+
dokkaSourceSets.configureEach {
240+
externalDocumentationLink {
241+
url.set(new URL(core_docs_url))
242+
packageListUrl.set(new File(core_docs_file).toURI().toURL())
243+
}
247244
}
248245
}
249246
}
@@ -276,15 +273,43 @@ apply plugin: 'kotlinx-knit'
276273
knit {
277274
siteRoot = "https://kotlin.github.io/kotlinx.coroutines"
278275
moduleRoots = [".", "integration", "reactive", "ui"]
276+
moduleDocs = "build/dokka/htmlPartial"
277+
dokkaMultiModuleRoot = "build/dokka/htmlMultiModule/"
279278
}
280279

281-
knitPrepare.dependsOn getTasksByName("dokka", true)
280+
knitPrepare.dependsOn getTasksByName("dokkaHtmlMultiModule", true)
282281

283-
// Disable binary compatibility check for JVM IR compiler output by default
284-
if (jvm_ir_enabled) {
285-
subprojects { project ->
286-
configure(tasks.matching { it.name == "apiCheck" }) {
287-
enabled = enabled && jvm_ir_api_check_enabled
288-
}
282+
dependencies {
283+
dokkaHtmlMultiModulePlugin("org.jetbrains.kotlinx:dokka-pathsaver-plugin:$knit_version")
284+
}
285+
286+
// Opt-in for build scan in order to troubleshoot Gradle on TC
287+
if (hasProperty('buildScan')) {
288+
buildScan {
289+
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
290+
termsOfServiceAgree = 'yes'
289291
}
290292
}
293+
294+
/*
295+
* kotlinx-coroutines-core dependency leaks into test runtime classpath via kotlin-compiler-embeddable
296+
* and conflicts with our own test/runtime incompatibilities (e.g. when class is moved from a main to test),
297+
* so we do substitution here
298+
*/
299+
allprojects { subProject ->
300+
subProject
301+
.configurations
302+
.matching {
303+
// Excluding substituted project itself because of circular dependencies, but still do it
304+
// for "*Test*" configurations
305+
subProject.name != "kotlinx-coroutines-core" || it.name.contains("Test")
306+
}
307+
.configureEach { conf ->
308+
conf.resolutionStrategy.dependencySubstitution {
309+
substitute(module("org.jetbrains.kotlinx:kotlinx-coroutines-core"))
310+
.using(project(":kotlinx-coroutines-core"))
311+
.because("Because Kotlin compiler embeddable leaks coroutines into the runtime classpath, " +
312+
"triggering all sort of incompatible class changes errors")
313+
}
314+
}
315+
}

buildSrc/build.gradle.kts

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@ val cacheRedirectorEnabled = System.getenv("CACHE_REDIRECTOR")?.toBoolean() == t
1212
val buildSnapshotTrain = properties["build_snapshot_train"]?.toString()?.toBoolean() == true
1313

1414
repositories {
15+
mavenCentral()
1516
if (cacheRedirectorEnabled) {
1617
maven("https://cache-redirector.jetbrains.com/plugins.gradle.org/m2")
17-
maven("https://cache-redirector.jetbrains.com/dl.bintray.com/kotlin/kotlin-dev")
1818
} else {
1919
maven("https://plugins.gradle.org/m2")
20-
// Leftover until we migrated to Dokka 1.4.30
21-
maven("https://dl.bintray.com/kotlin/kotlin-dev")
2220
}
2321
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev")
2422

@@ -47,4 +45,5 @@ fun version(target: String): String {
4745
dependencies {
4846
implementation(kotlin("gradle-plugin", version("kotlin")))
4947
implementation("org.jetbrains.dokka:dokka-gradle-plugin:${version("dokka")}")
48+
implementation("org.jetbrains.dokka:dokka-core:${version("dokka")}")
5049
}

buildSrc/settings.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
pluginManagement {
55
val build_snapshot_train: String? by settings
66
repositories {
7+
maven(url = "https://maven.pkg.jetbrains.space/kotlin/p/dokka/dev/")
78
val cacheRedirectorEnabled = System.getenv("CACHE_REDIRECTOR")?.toBoolean() == true
89
if (cacheRedirectorEnabled) {
910
println("Redirecting repositories for buildSrc buildscript")

0 commit comments

Comments
 (0)