playframework / playframework/play-ws
Scala example doesn't terminate
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 224
- Forks
- 92
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 28
Description
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)
libraryDependencies += "com.typesafe.play" %% "play-ahc-ws-standalone" % "1.1.3",
libraryDependencies += "com.typesafe.play" %% "play-ws-standalone-json" % "1.1.3",
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()
// 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")
}
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Hello.scala reproduction and run sbt run to observe the response and non-termination. Trace the call completion through wsClient.close() and system.terminate(); done means the example exits and returns the prompt after printing the response.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100