Skip to content

Commit b0dfdcd

Browse files
mpetrovqwwdfsad
authored andcommitted
Guava: Support building with Guava 27.
Several methods were deprecated, and removed in Guava 27. This updates existing calls to enable compiling with newer versions of Guava.
1 parent c26e071 commit b0dfdcd

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

integration/kotlinx-coroutines-guava/src/ListenableFuture.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public fun <T> CoroutineScope.future(
4040
val newContext = newCoroutineContext(context)
4141
val future = SettableFuture.create<T>()
4242
val coroutine = ListenableFutureCoroutine(newContext, future)
43-
future.addCallback(coroutine, MoreExecutors.directExecutor())
43+
Futures.addCallback(future, coroutine, MoreExecutors.directExecutor())
4444
coroutine.start(start, coroutine, block)
4545
return future
4646
}

integration/kotlinx-coroutines-guava/test/ListenableFutureExceptionsTest.kt

+11-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
package kotlinx.coroutines.guava
66

7+
import com.google.common.base.*
78
import com.google.common.util.concurrent.*
89
import kotlinx.coroutines.*
910
import org.junit.Test
@@ -55,7 +56,11 @@ class ListenableFutureExceptionsTest : TestBase() {
5556
// Fast path
5657
runTest {
5758
val future = SettableFuture.create<Int>()
58-
val chained = if (transformer == null) future else Futures.transform(future, transformer)
59+
val chained = if (transformer == null) {
60+
future
61+
} else {
62+
Futures.transform(future, Function(transformer), MoreExecutors.directExecutor())
63+
}
5964
future.setException(exception)
6065
try {
6166
chained.await()
@@ -67,7 +72,11 @@ class ListenableFutureExceptionsTest : TestBase() {
6772
// Slow path
6873
runTest {
6974
val future = SettableFuture.create<Int>()
70-
val chained = if (transformer == null) future else Futures.transform(future, transformer)
75+
val chained = if (transformer == null) {
76+
future
77+
} else {
78+
Futures.transform(future, Function(transformer), MoreExecutors.directExecutor())
79+
}
7180
launch {
7281
future.setException(exception)
7382
}

0 commit comments

Comments
 (0)