You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def main(args: Array[String]): Unit = {
// Create Akka system for thread and streaming management
implicit val system = ActorSystem()
system.registerOnTermination {
System.exit(0)
}
implicit val materializer = ActorMaterializer()
// Create the standalone WS client
// no argument defaults to a AhcWSClientConfig created from
// "AhcWSClientConfigFactory.forConfig(ConfigFactory.load, this.getClass.getClassLoader)"
val wsClient = StandaloneAhcWSClient()
call(wsClient)
.andThen { case _ => wsClient.close() }
.andThen { case _ => system.terminate() }
}
def call(wsClient: StandaloneWSClient): Future[Unit] = {
wsClient.url("http://www.google.com").get().map { response ⇒
val statusText: String = response.statusText
val body = response.body[String]
println(s"Got a response $statusText")
}
}
}
The text was updated successfully, but these errors were encountered:
Are you looking for help?
The current Play-WS standalone Scala example doesn't terminate.
sbt new scala/scala-seed.g8
Play WS Version (2.5.x / etc)
I used the following to create the project:
sbt new scala/scala-seed.g8
added the following to the build.sbt
libraryDependencies += "com.typesafe.play" %% "play-ahc-ws-standalone" % "1.1.3",
libraryDependencies += "com.typesafe.play" %% "play-ws-standalone-json" % "1.1.3",
libraryDependencies += "org.slf4j" % "slf4j-jdk14" % "1.7.9"
API (Scala / Java / Neither / Both)
Scala
Operating System (Ubuntu 15.10 / MacOS 10.10 / Windows 10)
Linux myMachine 4.13.0-32-generic #35~16.04.1-Ubuntu SMP Thu Jan 25 10:13:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
JDK (Oracle 1.8.0_72, OpenJDK 1.8.x, Azul Zing)
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)
Library Dependencies
Expected Behavior
sbt run returns
Actual Behavior
Output: Got a response OK
No prompt. I expect the example to terminate properly.
Reproducible Test Case
build.sbt:
import Dependencies._
lazy val root = (project in file(".")).
settings(
inThisBuild(List(
organization := "com.example",
scalaVersion := "2.12.4",
version := "0.1.0-SNAPSHOT"
)),
name := "demo",
libraryDependencies += "com.typesafe.play" %% "play-ahc-ws-standalone" % "1.1.3",
libraryDependencies += "com.typesafe.play" %% "play-ws-standalone-json" % "1.1.3",
libraryDependencies += "org.slf4j" % "slf4j-jdk14" % "1.7.9",
libraryDependencies += scalaTest % Test
)
Hello.scala:
package example
import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import play.api.libs.ws._
import play.api.libs.ws.ahc._
import scala.concurrent.Future
object Hello {
import DefaultBodyReadables._
import scala.concurrent.ExecutionContext.Implicits._
def main(args: Array[String]): Unit = {
// Create Akka system for thread and streaming management
implicit val system = ActorSystem()
system.registerOnTermination {
System.exit(0)
}
implicit val materializer = ActorMaterializer()
}
def call(wsClient: StandaloneWSClient): Future[Unit] = {
wsClient.url("http://www.google.com").get().map { response ⇒
val statusText: String = response.statusText
val body = response.body[String]
println(s"Got a response $statusText")
}
}
}
The text was updated successfully, but these errors were encountered: