Skip to content

Commit

Permalink
Merge pull request Kotlin#1872 from Kotlin/version-1.3.5
Browse files Browse the repository at this point in the history
Version 1.3.5
  • Loading branch information
qwwdfsad committed Mar 17, 2020
2 parents 2d0e862 + 98ab2dc commit 3bb3e55
Show file tree
Hide file tree
Showing 83 changed files with 2,506 additions and 201 deletions.
13 changes: 13 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Change log for kotlinx.coroutines

## Version 1.3.5

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

## Version 1.3.4

### Flow
Expand Down
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![official JetBrains project](https://jb.gg/badges/official.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)
[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](https://www.apache.org/licenses/LICENSE-2.0)
[![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)
[![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)

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

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

```groovy
dependencies {
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.4'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5'
}
```

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

```groovy
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.4")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5")
}
```

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

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

```groovy
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.4'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.5'
```

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

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

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

### Native

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

Only single-threaded code (JS-style) on Kotlin/Native is currently supported.
Expand Down Expand Up @@ -277,6 +278,7 @@ The `develop` branch is pushed to `master` during release.
[ListenableFuture.await]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-guava/kotlinx.coroutines.guava/com.google.common.util.concurrent.-listenable-future/await.html
<!--- MODULE kotlinx-coroutines-play-services -->
<!--- INDEX kotlinx.coroutines.tasks -->
[Task.await]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-play-services/kotlinx.coroutines.tasks/com.google.android.gms.tasks.-task/await.html
<!--- MODULE kotlinx-coroutines-reactive -->
<!--- INDEX kotlinx.coroutines.reactive -->
[Publisher.collect]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-reactive/kotlinx.coroutines.reactive/org.reactivestreams.-publisher/collect.html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ package benchmarks.flow.scrabble

import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.flow.Flow
import org.openjdk.jmh.annotations.*
import java.lang.Long.*
import java.util.*
import java.util.concurrent.*
import kotlin.math.*

@Warmup(iterations = 7, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 7, time = 1, timeUnit = TimeUnit.SECONDS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
package benchmarks.flow.scrabble

import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
import org.openjdk.jmh.annotations.*
import java.lang.Long.*
import java.util.*
import java.util.concurrent.*
import java.util.concurrent.TimeUnit

@Warmup(iterations = 7, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 7, time = 1, timeUnit = TimeUnit.SECONDS)
Expand Down
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ allprojects {
apply plugin: "binary-compatibility-validator"
apiValidation {
ignoredProjects += unpublished + ["kotlinx-coroutines-bom"]
if (build_snapshot_train) {
ignoredProjects.remove("site")
ignoredProjects.remove("example-frontend-js")
}
ignoredPackages += "kotlinx.coroutines.internal"
}

Expand Down Expand Up @@ -305,4 +309,4 @@ knit {
moduleRoots = [".", "integration", "reactive", "ui"]
}

knitPrepare.dependsOn getTasksByName("dokka", true)
knitPrepare.dependsOn getTasksByName("dokka", true)
9 changes: 7 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#

# Kotlin
version=1.3.4-SNAPSHOT
version=1.3.5-SNAPSHOT
group=org.jetbrains.kotlinx
kotlin_version=1.3.70

Expand All @@ -20,7 +20,7 @@ reactive_streams_version=1.0.2
rxjava2_version=2.2.8
javafx_version=11.0.2
javafx_plugin_version=0.0.8
binary_compatibility_validator_version=0.1.1
binary_compatibility_validator_version=0.2.2

# Android versions
android_version=4.1.1.4
Expand All @@ -29,6 +29,7 @@ robolectric_version=4.0.2
baksmali_version=2.2.7

# JS
kotlin.js.compiler=both
gradle_node_version=1.2.0
node_version=8.9.3
npm_version=5.7.1
Expand All @@ -43,3 +44,7 @@ kotlin.native.ignoreDisabledTargets=true

# Site deneration
jekyll_version=4.0

# JS IR baceknd sometimes crashes with out-of-memory
# TODO: Remove once KT-37187 is fixed
org.gradle.jvmargs=-Xmx2g
17 changes: 15 additions & 2 deletions gradle/compile-js-multiplatform.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@ apply from: rootProject.file('gradle/node-js.gradle')

kotlin {
targets {
fromPreset(presets.js, 'js')
fromPreset(presets.js, 'js') {
// Enable built-in test runner only for IR target.
// These runners don't support changing js module name change.
if (js.hasProperty("irTarget")) {
irTarget.nodejs()
irTarget?.compilations['main']?.dependencies {
api "org.jetbrains.kotlinx:atomicfu-js:$atomicfu_version"
}
}
}
}

sourceSets {
Expand Down Expand Up @@ -41,12 +50,16 @@ compileTestKotlinJs {
kotlinOptions.moduleKind = 'umd'
}


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

def configuration = configurations.jsTestRuntimeClasspath
def configuration = configurations.hasProperty("legacyjsTestRuntimeClasspath")
? configurations.legacyjsTestRuntimeClasspath
: configurations.jsTestRuntimeClasspath

from(files {
configuration.collect { File file ->
file.name.endsWith(".jar") ?
Expand Down
4 changes: 2 additions & 2 deletions gradle/publish-bintray.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ publishing {
break
}

// disable metadata everywhere, but in native modules
if (type == 'maven' || type == 'metadata' || type == 'jvm' || type == 'js') {
// disable metadata everywhere, but in native and js modules
if (type == 'maven' || type == 'metadata' || type == 'jvm') {
moduleDescriptorGenerator = null
}
}
Expand Down
6 changes: 4 additions & 2 deletions gradle/test-mocha-js.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ task testMochaNode(type: NodeTask, dependsOn: [compileTestKotlinJs, installDepen
if (project.hasProperty("teamcity")) args += ['--reporter', 'mocha-teamcity-reporter']
}

jsTest.dependsOn testMochaNode
def legacyjsTestTask = project.tasks.findByName('legacyjsTest') ? legacyjsTest : jsTest

legacyjsTestTask.dependsOn testMochaNode

// -- Testing with Mocha under headless Chrome

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

jsTest.dependsOn testMochaJsdom
legacyjsTestTask.dependsOn testMochaJsdom

Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ public final class kotlinx/coroutines/stream/StreamKt {
}

public final class kotlinx/coroutines/time/TimeKt {
public static final fun debounce (Lkotlinx/coroutines/flow/Flow;Ljava/time/Duration;)Lkotlinx/coroutines/flow/Flow;
public static final fun delay (Ljava/time/Duration;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun onTimeout (Lkotlinx/coroutines/selects/SelectBuilder;Ljava/time/Duration;Lkotlin/jvm/functions/Function1;)V
public static final fun sample (Lkotlinx/coroutines/flow/Flow;Ljava/time/Duration;)Lkotlinx/coroutines/flow/Flow;
public static final fun withTimeout (Ljava/time/Duration;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun withTimeoutOrNull (Ljava/time/Duration;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}
Expand Down
13 changes: 13 additions & 0 deletions integration/kotlinx-coroutines-jdk8/src/time/Time.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package kotlinx.coroutines.time

import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.selects.*
import java.time.*
import java.time.temporal.*
Expand All @@ -14,6 +15,18 @@ import java.time.temporal.*
public suspend fun delay(duration: Duration) =
kotlinx.coroutines.delay(duration.coerceToMillis())

/**
* "java.time" adapter method for [kotlinx.coroutines.flow.debounce].
*/
@FlowPreview
public fun <T> Flow<T>.debounce(timeout: Duration) = debounce(timeout.coerceToMillis())

/**
* "java.time" adapter method for [kotlinx.coroutines.flow.sample].
*/
@FlowPreview
public fun <T> Flow<T>.sample(period: Duration) = sample(period.coerceToMillis())

/**
* "java.time" adapter method for [SelectBuilder.onTimeout].
*/
Expand Down
38 changes: 38 additions & 0 deletions integration/kotlinx-coroutines-jdk8/test/time/FlowDebounceTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

package kotlinx.coroutines.time

import kotlinx.coroutines.TestBase
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.toList
import kotlinx.coroutines.withVirtualTime
import org.junit.Test
import java.time.Duration
import kotlin.test.assertEquals

class FlowDebounceTest : TestBase() {
@Test
public fun testBasic() = withVirtualTime {
expect(1)
val flow = flow {
expect(3)
emit("A")
delay(Duration.ofMillis(1500))
emit("B")
delay(Duration.ofMillis(500))
emit("C")
delay(Duration.ofMillis(250))
emit("D")
delay(Duration.ofMillis(2000))
emit("E")
expect(4)
}

expect(2)
val result = flow.debounce(Duration.ofMillis(1000)).toList()
assertEquals(listOf("A", "D", "E"), result)
finish(5)
}
}
39 changes: 39 additions & 0 deletions integration/kotlinx-coroutines-jdk8/test/time/FlowSampleTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

package kotlinx.coroutines.time

import kotlinx.coroutines.TestBase
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.toList
import kotlinx.coroutines.withVirtualTime
import org.junit.Test
import java.time.Duration
import kotlin.test.assertEquals


class SampleTest : TestBase() {
@Test
public fun testBasic() = withVirtualTime {
expect(1)
val flow = flow {
expect(3)
emit("A")
delay(Duration.ofMillis(1500))
emit("B")
delay(Duration.ofMillis(500))
emit("C")
delay(Duration.ofMillis(250))
emit("D")
delay(Duration.ofMillis(2000))
emit("E")
expect(4)
}

expect(2)
val result = flow.sample(Duration.ofMillis(1000)).toList()
assertEquals(listOf("A", "B", "D"), result)
finish(5)
}
}
18 changes: 18 additions & 0 deletions js/example-frontend-js/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@
apply plugin: 'kotlin-dce-js'
apply from: rootProject.file('gradle/node-js.gradle')

// Workaround resolving new Gradle metadata with kotlin2js
// TODO: Remove once KT-37188 is fixed
try {
def jsCompilerType = Class.forName("org.jetbrains.kotlin.gradle.targets.js.JsCompilerType")
def jsCompilerAttr = Attribute.of("org.jetbrains.kotlin.js.compiler", jsCompilerType)
project.dependencies.attributesSchema.attribute(jsCompilerAttr)
configurations {
matching {
it.name.endsWith("Classpath")
}.forEach {
it.attributes.attribute(jsCompilerAttr, jsCompilerType.legacy)
}
}
} catch (java.lang.ClassNotFoundException e) {
// org.jetbrains.kotlin.gradle.targets.js.JsCompilerType is missing in 1.3.x
// But 1.3.x doesn't generate Gradle metadata, so this workaround is not needed
}

dependencies {
compile "org.jetbrains.kotlinx:kotlinx-html-js:$html_version"
}
Expand Down
Loading

0 comments on commit 3bb3e55

Please sign in to comment.