This is an automated email from the ASF dual-hosted git repository.
markusthoemmes pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwhisk.git
The following commit(s) were added to refs/heads/master by this push:
new d3bb290 Remove usages of rxscala and replace with Java based code.
(#4744)
d3bb290 is described below
commit d3bb290432d4403155e92918f4ddc2c692eefa99
Author: Markus Thömmes <[email protected]>
AuthorDate: Fri Nov 22 13:31:47 2019 +0100
Remove usages of rxscala and replace with Java based code. (#4744)
* Remove usages of rxscala and replace with Java based code.
* Convert to SAM.
* Fix rebase screw up.
---
common/scala/build.gradle | 2 +-
.../core/database/cosmosdb/RxObservableImplicits.scala | 10 ++++++----
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/common/scala/build.gradle b/common/scala/build.gradle
index d54b62e..9d57b4e 100644
--- a/common/scala/build.gradle
+++ b/common/scala/build.gradle
@@ -81,7 +81,7 @@ dependencies {
compile "io.zipkin.reporter2:zipkin-sender-okhttp3:2.6.1"
compile "io.zipkin.reporter2:zipkin-reporter:2.6.1"
- compile "io.reactivex:rxscala_${gradle.scala.depVersion}:0.26.5"
+ compile "io.reactivex:rxjava:1.3.8"
compile "io.reactivex:rxjava-reactive-streams:1.2.1"
compile "com.microsoft.azure:azure-cosmosdb:2.6.2"
diff --git
a/common/scala/src/main/scala/org/apache/openwhisk/core/database/cosmosdb/RxObservableImplicits.scala
b/common/scala/src/main/scala/org/apache/openwhisk/core/database/cosmosdb/RxObservableImplicits.scala
index cf9e79c..53f303c 100644
---
a/common/scala/src/main/scala/org/apache/openwhisk/core/database/cosmosdb/RxObservableImplicits.scala
+++
b/common/scala/src/main/scala/org/apache/openwhisk/core/database/cosmosdb/RxObservableImplicits.scala
@@ -18,8 +18,8 @@
package org.apache.openwhisk.core.database.cosmosdb
import com.microsoft.azure.cosmosdb.{FeedResponse, Resource, ResourceResponse}
-import rx.lang.scala.JavaConverters._
import rx.Observable
+import rx.functions.Action1
import scala.collection.JavaConverters._
import scala.concurrent.{Future, Promise}
@@ -34,8 +34,10 @@ private[cosmosdb] trait RxObservableImplicits {
* @return the head result of the [[Observable]].
*/
def head(): Future[T] = {
+ def toHandler[P](f: (P) => Unit): Action1[P] = (t: P) => f(t)
+
val promise = Promise[T]()
- observable.asScala.single.subscribe(x => promise.success(x), e =>
promise.failure(e))
+ observable.single.subscribe(toHandler(promise.success),
toHandler(promise.failure))
promise.future
}
}
@@ -46,8 +48,8 @@ private[cosmosdb] trait RxObservableImplicits {
implicit class RxScalaFeedObservable[T <: Resource](observable:
Observable[FeedResponse[T]]) {
def blockingOnlyResult(): Option[T] = {
- val value = observable.asScala.toList.toBlocking.single
- val results = value.head.getResults.asScala
+ val value = observable.toBlocking.single
+ val results = value.getResults.asScala
require(results.isEmpty || results.size == 1, s"More than one result
found $results")
results.headOption
}