Skip to content

Commit 3bb3e55

Browse files
authored
Merge pull request #1872 from Kotlin/version-1.3.5
Version 1.3.5
2 parents 2d0e862 + 98ab2dc commit 3bb3e55

File tree

83 files changed

+2506
-201
lines changed

Some content is hidden

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

83 files changed

+2506
-201
lines changed

CHANGES.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Change log for kotlinx.coroutines
22

3+
## Version 1.3.5
4+
5+
* `firstOrNull` operator. Contributed by @bradynpoulsen.
6+
* `java.time` adapters for Flow operators. Contributed by @fvasco.
7+
* `kotlin.time.Duration` support (#1402). Contributed by @fvasco.
8+
* Memory leak with a mix of reusable and non-reusable continuations is fixed (#1855).
9+
* `DebugProbes` are ready for production installation: its performance is increased, the flag to disable creation stacktraces to reduce the footprint is introduced (#1379, #1372).
10+
* Stacktrace recovery workaround for Android 6.0 and earlier bug (#1866).
11+
* New integration module: `kotlinx-coroutines-jdk9` with adapters for `java.util.concurrent.Flow`.
12+
* `BroadcastChannel.close` properly starts lazy coroutine (#1713).
13+
* `kotlinx-coroutines-bom` is published without Gradle metadata.
14+
* Make calls to service loader in reactor integrations optimizable by R8 (#1817).
15+
316
## Version 1.3.4
417

518
### Flow

README.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
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://api.bintray.com/packages/kotlin/kotlinx/kotlinx.coroutines/images/download.svg?version=1.3.4) ](https://bintray.com/kotlin/kotlinx/kotlinx.coroutines/1.3.4)
5+
[![Download](https://api.bintray.com/packages/kotlin/kotlinx/kotlinx.coroutines/images/download.svg?version=1.3.5) ](https://bintray.com/kotlin/kotlinx/kotlinx.coroutines/1.3.5)
66

77
Library support for Kotlin coroutines with [multiplatform](#multiplatform) support.
88
This is a companion version for Kotlin `1.3.70` release.
@@ -45,8 +45,9 @@ suspend fun main() = coroutineScope {
4545
* [CoroutinesTimeout] test rule to automatically dump coroutines on test timeout.
4646
* [reactive](reactive/README.md) — modules that provide builders and iteration support for various reactive streams libraries:
4747
* Reactive Streams ([Publisher.collect], [Publisher.awaitSingle], [publish], etc),
48-
RxJava 2.x ([rxFlowable], [rxSingle], etc), and
49-
Project Reactor ([flux], [mono], etc).
48+
* Flow (JDK 9) (the same interface as for Reactive Streams),
49+
* RxJava 2.x ([rxFlowable], [rxSingle], etc), and
50+
* Project Reactor ([flux], [mono], etc).
5051
* [ui](ui/README.md) — modules that provide coroutine dispatchers for various single-threaded UI libraries:
5152
* Android, JavaFX, and Swing.
5253
* [integration](integration/README.md) — modules that provide integration with various asynchronous callback- and future-based libraries:
@@ -82,7 +83,7 @@ Add dependencies (you can also add other modules that you need):
8283
<dependency>
8384
<groupId>org.jetbrains.kotlinx</groupId>
8485
<artifactId>kotlinx-coroutines-core</artifactId>
85-
<version>1.3.4</version>
86+
<version>1.3.5</version>
8687
</dependency>
8788
```
8889

@@ -100,7 +101,7 @@ Add dependencies (you can also add other modules that you need):
100101

101102
```groovy
102103
dependencies {
103-
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.4'
104+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5'
104105
}
105106
```
106107

@@ -126,7 +127,7 @@ Add dependencies (you can also add other modules that you need):
126127

127128
```groovy
128129
dependencies {
129-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.4")
130+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5")
130131
}
131132
```
132133

@@ -145,7 +146,7 @@ Make sure that you have either `jcenter()` or `mavenCentral()` in the list of re
145146
Core modules of `kotlinx.coroutines` are also available for
146147
[Kotlin/JS](#js) and [Kotlin/Native](#native).
147148
In common code that should get compiled for different platforms, add dependency to
148-
[`kotlinx-coroutines-core-common`](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core-common/1.3.4/jar)
149+
[`kotlinx-coroutines-core-common`](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core-common/1.3.5/jar)
149150
(follow the link to get the dependency declaration snippet).
150151

151152
### Android
@@ -154,7 +155,7 @@ Add [`kotlinx-coroutines-android`](ui/kotlinx-coroutines-android)
154155
module as dependency when using `kotlinx.coroutines` on Android:
155156

156157
```groovy
157-
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.4'
158+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.5'
158159
```
159160

160161
This gives you access to Android [Dispatchers.Main]
@@ -170,15 +171,15 @@ For more details see ["Optimization" section for Android](ui/kotlinx-coroutines-
170171
### JS
171172

172173
[Kotlin/JS](https://kotlinlang.org/docs/reference/js-overview.html) version of `kotlinx.coroutines` is published as
173-
[`kotlinx-coroutines-core-js`](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core-js/1.3.4/jar)
174+
[`kotlinx-coroutines-core-js`](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core-js/1.3.5/jar)
174175
(follow the link to get the dependency declaration snippet).
175176

176177
You can also use [`kotlinx-coroutines-core`](https://www.npmjs.com/package/kotlinx-coroutines-core) package via NPM.
177178

178179
### Native
179180

180181
[Kotlin/Native](https://kotlinlang.org/docs/reference/native-overview.html) version of `kotlinx.coroutines` is published as
181-
[`kotlinx-coroutines-core-native`](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core-native/1.3.4/jar)
182+
[`kotlinx-coroutines-core-native`](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core-native/1.3.5/jar)
182183
(follow the link to get the dependency declaration snippet).
183184

184185
Only single-threaded code (JS-style) on Kotlin/Native is currently supported.
@@ -277,6 +278,7 @@ The `develop` branch is pushed to `master` during release.
277278
[ListenableFuture.await]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-guava/kotlinx.coroutines.guava/com.google.common.util.concurrent.-listenable-future/await.html
278279
<!--- MODULE kotlinx-coroutines-play-services -->
279280
<!--- INDEX kotlinx.coroutines.tasks -->
281+
[Task.await]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-play-services/kotlinx.coroutines.tasks/com.google.android.gms.tasks.-task/await.html
280282
<!--- MODULE kotlinx-coroutines-reactive -->
281283
<!--- INDEX kotlinx.coroutines.reactive -->
282284
[Publisher.collect]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-reactive/kotlinx.coroutines.reactive/org.reactivestreams.-publisher/collect.html

benchmarks/src/jmh/kotlin/benchmarks/flow/scrabble/FlowPlaysScrabbleOpt.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ package benchmarks.flow.scrabble
66

77
import kotlinx.coroutines.*
88
import kotlinx.coroutines.flow.*
9+
import kotlinx.coroutines.flow.Flow
910
import org.openjdk.jmh.annotations.*
10-
import java.lang.Long.*
1111
import java.util.*
1212
import java.util.concurrent.*
13+
import kotlin.math.*
1314

1415
@Warmup(iterations = 7, time = 1, timeUnit = TimeUnit.SECONDS)
1516
@Measurement(iterations = 7, time = 1, timeUnit = TimeUnit.SECONDS)

benchmarks/src/jmh/kotlin/benchmarks/flow/scrabble/SequencePlaysScrabble.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
package benchmarks.flow.scrabble
66

77
import kotlinx.coroutines.*
8+
import kotlinx.coroutines.flow.*
89
import org.openjdk.jmh.annotations.*
910
import java.lang.Long.*
1011
import java.util.*
11-
import java.util.concurrent.*
12+
import java.util.concurrent.TimeUnit
1213

1314
@Warmup(iterations = 7, time = 1, timeUnit = TimeUnit.SECONDS)
1415
@Measurement(iterations = 7, time = 1, timeUnit = TimeUnit.SECONDS)

build.gradle

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ allprojects {
134134
apply plugin: "binary-compatibility-validator"
135135
apiValidation {
136136
ignoredProjects += unpublished + ["kotlinx-coroutines-bom"]
137+
if (build_snapshot_train) {
138+
ignoredProjects.remove("site")
139+
ignoredProjects.remove("example-frontend-js")
140+
}
137141
ignoredPackages += "kotlinx.coroutines.internal"
138142
}
139143

@@ -305,4 +309,4 @@ knit {
305309
moduleRoots = [".", "integration", "reactive", "ui"]
306310
}
307311

308-
knitPrepare.dependsOn getTasksByName("dokka", true)
312+
knitPrepare.dependsOn getTasksByName("dokka", true)

gradle.properties

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44

55
# Kotlin
6-
version=1.3.4-SNAPSHOT
6+
version=1.3.5-SNAPSHOT
77
group=org.jetbrains.kotlinx
88
kotlin_version=1.3.70
99

@@ -20,7 +20,7 @@ reactive_streams_version=1.0.2
2020
rxjava2_version=2.2.8
2121
javafx_version=11.0.2
2222
javafx_plugin_version=0.0.8
23-
binary_compatibility_validator_version=0.1.1
23+
binary_compatibility_validator_version=0.2.2
2424

2525
# Android versions
2626
android_version=4.1.1.4
@@ -29,6 +29,7 @@ robolectric_version=4.0.2
2929
baksmali_version=2.2.7
3030

3131
# JS
32+
kotlin.js.compiler=both
3233
gradle_node_version=1.2.0
3334
node_version=8.9.3
3435
npm_version=5.7.1
@@ -43,3 +44,7 @@ kotlin.native.ignoreDisabledTargets=true
4344

4445
# Site deneration
4546
jekyll_version=4.0
47+
48+
# JS IR baceknd sometimes crashes with out-of-memory
49+
# TODO: Remove once KT-37187 is fixed
50+
org.gradle.jvmargs=-Xmx2g

gradle/compile-js-multiplatform.gradle

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,16 @@ apply from: rootProject.file('gradle/node-js.gradle')
66

77
kotlin {
88
targets {
9-
fromPreset(presets.js, 'js')
9+
fromPreset(presets.js, 'js') {
10+
// Enable built-in test runner only for IR target.
11+
// These runners don't support changing js module name change.
12+
if (js.hasProperty("irTarget")) {
13+
irTarget.nodejs()
14+
irTarget?.compilations['main']?.dependencies {
15+
api "org.jetbrains.kotlinx:atomicfu-js:$atomicfu_version"
16+
}
17+
}
18+
}
1019
}
1120

1221
sourceSets {
@@ -41,12 +50,16 @@ compileTestKotlinJs {
4150
kotlinOptions.moduleKind = 'umd'
4251
}
4352

53+
4454
task populateNodeModules(type: Copy, dependsOn: compileTestKotlinJs) {
4555
// we must copy output that is transformed by atomicfu
4656
from(kotlin.targets.js.compilations.main.output.allOutputs)
4757
into "$node.nodeModulesDir/node_modules"
4858

49-
def configuration = configurations.jsTestRuntimeClasspath
59+
def configuration = configurations.hasProperty("legacyjsTestRuntimeClasspath")
60+
? configurations.legacyjsTestRuntimeClasspath
61+
: configurations.jsTestRuntimeClasspath
62+
5063
from(files {
5164
configuration.collect { File file ->
5265
file.name.endsWith(".jar") ?

gradle/publish-bintray.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ publishing {
8989
break
9090
}
9191

92-
// disable metadata everywhere, but in native modules
93-
if (type == 'maven' || type == 'metadata' || type == 'jvm' || type == 'js') {
92+
// disable metadata everywhere, but in native and js modules
93+
if (type == 'maven' || type == 'metadata' || type == 'jvm') {
9494
moduleDescriptorGenerator = null
9595
}
9696
}

gradle/test-mocha-js.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ task testMochaNode(type: NodeTask, dependsOn: [compileTestKotlinJs, installDepen
1919
if (project.hasProperty("teamcity")) args += ['--reporter', 'mocha-teamcity-reporter']
2020
}
2121

22-
jsTest.dependsOn testMochaNode
22+
def legacyjsTestTask = project.tasks.findByName('legacyjsTest') ? legacyjsTest : jsTest
23+
24+
legacyjsTestTask.dependsOn testMochaNode
2325

2426
// -- Testing with Mocha under headless Chrome
2527

@@ -89,5 +91,5 @@ task testMochaJsdom(type: NodeTask, dependsOn: [compileTestKotlinJs, installDepe
8991
if (project.hasProperty("teamcity")) args += ['--reporter', 'mocha-teamcity-reporter']
9092
}
9193

92-
jsTest.dependsOn testMochaJsdom
94+
legacyjsTestTask.dependsOn testMochaJsdom
9395

integration/kotlinx-coroutines-jdk8/api/kotlinx-coroutines-jdk8.api

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ public final class kotlinx/coroutines/stream/StreamKt {
1212
}
1313

1414
public final class kotlinx/coroutines/time/TimeKt {
15+
public static final fun debounce (Lkotlinx/coroutines/flow/Flow;Ljava/time/Duration;)Lkotlinx/coroutines/flow/Flow;
1516
public static final fun delay (Ljava/time/Duration;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
1617
public static final fun onTimeout (Lkotlinx/coroutines/selects/SelectBuilder;Ljava/time/Duration;Lkotlin/jvm/functions/Function1;)V
18+
public static final fun sample (Lkotlinx/coroutines/flow/Flow;Ljava/time/Duration;)Lkotlinx/coroutines/flow/Flow;
1719
public static final fun withTimeout (Ljava/time/Duration;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
1820
public static final fun withTimeoutOrNull (Ljava/time/Duration;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
1921
}

integration/kotlinx-coroutines-jdk8/src/time/Time.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package kotlinx.coroutines.time
55

66
import kotlinx.coroutines.*
7+
import kotlinx.coroutines.flow.*
78
import kotlinx.coroutines.selects.*
89
import java.time.*
910
import java.time.temporal.*
@@ -14,6 +15,18 @@ import java.time.temporal.*
1415
public suspend fun delay(duration: Duration) =
1516
kotlinx.coroutines.delay(duration.coerceToMillis())
1617

18+
/**
19+
* "java.time" adapter method for [kotlinx.coroutines.flow.debounce].
20+
*/
21+
@FlowPreview
22+
public fun <T> Flow<T>.debounce(timeout: Duration) = debounce(timeout.coerceToMillis())
23+
24+
/**
25+
* "java.time" adapter method for [kotlinx.coroutines.flow.sample].
26+
*/
27+
@FlowPreview
28+
public fun <T> Flow<T>.sample(period: Duration) = sample(period.coerceToMillis())
29+
1730
/**
1831
* "java.time" adapter method for [SelectBuilder.onTimeout].
1932
*/
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
package kotlinx.coroutines.time
6+
7+
import kotlinx.coroutines.TestBase
8+
import kotlinx.coroutines.flow.flow
9+
import kotlinx.coroutines.flow.toList
10+
import kotlinx.coroutines.withVirtualTime
11+
import org.junit.Test
12+
import java.time.Duration
13+
import kotlin.test.assertEquals
14+
15+
class FlowDebounceTest : TestBase() {
16+
@Test
17+
public fun testBasic() = withVirtualTime {
18+
expect(1)
19+
val flow = flow {
20+
expect(3)
21+
emit("A")
22+
delay(Duration.ofMillis(1500))
23+
emit("B")
24+
delay(Duration.ofMillis(500))
25+
emit("C")
26+
delay(Duration.ofMillis(250))
27+
emit("D")
28+
delay(Duration.ofMillis(2000))
29+
emit("E")
30+
expect(4)
31+
}
32+
33+
expect(2)
34+
val result = flow.debounce(Duration.ofMillis(1000)).toList()
35+
assertEquals(listOf("A", "D", "E"), result)
36+
finish(5)
37+
}
38+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
package kotlinx.coroutines.time
6+
7+
import kotlinx.coroutines.TestBase
8+
import kotlinx.coroutines.flow.flow
9+
import kotlinx.coroutines.flow.toList
10+
import kotlinx.coroutines.withVirtualTime
11+
import org.junit.Test
12+
import java.time.Duration
13+
import kotlin.test.assertEquals
14+
15+
16+
class SampleTest : TestBase() {
17+
@Test
18+
public fun testBasic() = withVirtualTime {
19+
expect(1)
20+
val flow = flow {
21+
expect(3)
22+
emit("A")
23+
delay(Duration.ofMillis(1500))
24+
emit("B")
25+
delay(Duration.ofMillis(500))
26+
emit("C")
27+
delay(Duration.ofMillis(250))
28+
emit("D")
29+
delay(Duration.ofMillis(2000))
30+
emit("E")
31+
expect(4)
32+
}
33+
34+
expect(2)
35+
val result = flow.sample(Duration.ofMillis(1000)).toList()
36+
assertEquals(listOf("A", "B", "D"), result)
37+
finish(5)
38+
}
39+
}

js/example-frontend-js/build.gradle

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,24 @@
55
apply plugin: 'kotlin-dce-js'
66
apply from: rootProject.file('gradle/node-js.gradle')
77

8+
// Workaround resolving new Gradle metadata with kotlin2js
9+
// TODO: Remove once KT-37188 is fixed
10+
try {
11+
def jsCompilerType = Class.forName("org.jetbrains.kotlin.gradle.targets.js.JsCompilerType")
12+
def jsCompilerAttr = Attribute.of("org.jetbrains.kotlin.js.compiler", jsCompilerType)
13+
project.dependencies.attributesSchema.attribute(jsCompilerAttr)
14+
configurations {
15+
matching {
16+
it.name.endsWith("Classpath")
17+
}.forEach {
18+
it.attributes.attribute(jsCompilerAttr, jsCompilerType.legacy)
19+
}
20+
}
21+
} catch (java.lang.ClassNotFoundException e) {
22+
// org.jetbrains.kotlin.gradle.targets.js.JsCompilerType is missing in 1.3.x
23+
// But 1.3.x doesn't generate Gradle metadata, so this workaround is not needed
24+
}
25+
826
dependencies {
927
compile "org.jetbrains.kotlinx:kotlinx-html-js:$html_version"
1028
}

0 commit comments

Comments
 (0)