Skip to content

Commit c4082e4

Browse files
committed
bump reactor-core to 3.4.x version and replace deprecated API usage
1 parent 7223897 commit c4082e4

File tree

7 files changed

+20
-15
lines changed

7 files changed

+20
-15
lines changed

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ html_version=0.6.8
1515
lincheck_version=2.7.1
1616
dokka_version=0.9.16-rdev-2-mpp-hacks
1717
byte_buddy_version=1.10.9
18-
reactor_version=3.2.5.RELEASE
18+
reactor_version=3.4.1
1919
reactive_streams_version=1.0.2
2020
rxjava2_version=2.2.8
2121
rxjava3_version=3.0.2

reactive/kotlinx-coroutines-reactor/build.gradle.kts

+5
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@ dependencies {
99
compile(project(":kotlinx-coroutines-reactive"))
1010
}
1111

12+
java {
13+
targetCompatibility = JavaVersion.VERSION_1_8
14+
sourceCompatibility = JavaVersion.VERSION_1_8
15+
}
1216

1317
tasks {
18+
1419
compileKotlin {
1520
kotlinOptions.jvmTarget = "1.8"
1621
}

reactive/kotlinx-coroutines-reactor/src/ReactorContext.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import kotlinx.coroutines.reactive.*
2424
* #### Propagating ReactorContext to Reactor's Context
2525
* ```
2626
* val flux = myDatabaseService.getUsers()
27-
* .subscriberContext() { ctx -> println(ctx); ctx }
27+
* .contextWrite { ctx -> println(ctx); ctx }
2828
* flux.await() // Will print "null"
2929
*
3030
* // Now add ReactorContext
@@ -43,7 +43,7 @@ import kotlinx.coroutines.reactive.*
4343
* .subscribe() // Will print 'Reactor context in Flow: null'
4444
* // Add subscriber's context
4545
* flow.asFlux()
46-
* .subscriberContext { ctx -> ctx.put("answer", 42) }
46+
* .contextWrite { ctx -> ctx.put("answer", 42) }
4747
* .subscribe() // Will print "Reactor context in Flow: Context{'answer'=42}"
4848
* ```
4949
*/

reactive/kotlinx-coroutines-reactor/src/ReactorContextInjector.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ internal class ReactorContextInjector : ContextInjector {
1818
override fun <T> injectCoroutineContext(publisher: Publisher<T>, coroutineContext: CoroutineContext): Publisher<T> {
1919
val reactorContext = coroutineContext[ReactorContext]?.context ?: return publisher
2020
return when(publisher) {
21-
is Mono -> publisher.subscriberContext(reactorContext)
22-
is Flux -> publisher.subscriberContext(reactorContext)
21+
is Mono -> publisher.contextWrite(reactorContext)
22+
is Flux -> publisher.contextWrite(reactorContext)
2323
else -> publisher
2424
}
2525
}

reactive/kotlinx-coroutines-reactor/test/FlowAsFluxTest.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ class FlowAsFluxTest : TestBase() {
1818
(1..4).forEach { i -> emit(createMono(i).awaitFirst()) }
1919
}
2020
.asFlux()
21-
.subscriberContext(Context.of(1, "1"))
22-
.subscriberContext(Context.of(2, "2", 3, "3", 4, "4"))
21+
.contextWrite(Context.of(1, "1"))
22+
.contextWrite(Context.of(2, "2", 3, "3", 4, "4"))
2323
val list = flux.collectList().block()!!
2424
assertEquals(listOf("1", "2", "3", "4"), list)
2525
}
@@ -36,7 +36,7 @@ class FlowAsFluxTest : TestBase() {
3636
it.next("OK")
3737
it.complete()
3838
}
39-
.subscriberContext { ctx ->
39+
.contextWrite { ctx ->
4040
expect(2)
4141
assertEquals("CTX", ctx.get(1))
4242
ctx
@@ -58,7 +58,7 @@ class FlowAsFluxTest : TestBase() {
5858
it.next("OK")
5959
it.complete()
6060
}
61-
.subscriberContext { ctx ->
61+
.contextWrite { ctx ->
6262
expect(2)
6363
assertEquals("CTX", ctx.get(1))
6464
ctx

reactive/kotlinx-coroutines-reactor/test/MonoTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ class MonoTest : TestBase() {
235235
} finally {
236236
throw TestException() // would not be able to handle it since mono is disposed
237237
}
238-
}.subscriberContext { Context.of("reactor.onOperatorError.local", handler) }
238+
}.contextWrite { Context.of("reactor.onOperatorError.local", handler) }
239239
mono.subscribe(object : Subscriber<Unit> {
240240
override fun onSubscribe(s: Subscription) {
241241
expect(2)

reactive/kotlinx-coroutines-reactor/test/ReactorContextTest.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ class ReactorContextTest : TestBase() {
1818
buildString {
1919
(1..7).forEach { append(ctx.getOrDefault(it, "noValue")) }
2020
}
21-
} .subscriberContext(Context.of(2, "2", 3, "3", 4, "4", 5, "5"))
22-
.subscriberContext { ctx -> ctx.put(6, "6") }
21+
} .contextWrite(Context.of(2, "2", 3, "3", 4, "4", 5, "5"))
22+
.contextWrite { ctx -> ctx.put(6, "6") }
2323
assertEquals(mono.awaitFirst(), "1234567")
2424
}
2525

@@ -29,8 +29,8 @@ class ReactorContextTest : TestBase() {
2929
val ctx = reactorContext()
3030
(1..7).forEach { send(ctx.getOrDefault(it, "noValue")) }
3131
}
32-
.subscriberContext(Context.of(2, "2", 3, "3", 4, "4", 5, "5"))
33-
.subscriberContext { ctx -> ctx.put(6, "6") }
32+
.contextWrite(Context.of(2, "2", 3, "3", 4, "4", 5, "5"))
33+
.contextWrite { ctx -> ctx.put(6, "6") }
3434
val list = flux.collectList().block()!!
3535
assertEquals((1..7).map { it.toString() }, list)
3636
}
@@ -42,7 +42,7 @@ class ReactorContextTest : TestBase() {
4242
buildString {
4343
(1..3).forEach { append(ctx.getOrDefault(it, "noValue")) }
4444
}
45-
} .subscriberContext(Context.of(2, "2"))
45+
} .contextWrite(Context.of(2, "2"))
4646
.awaitFirst()
4747
assertEquals(result, "123")
4848
}

0 commit comments

Comments
 (0)