Reputation: 70
I am trying to learn Scala and have the following issue, when running the below program the response is printed but it never terminates:
object Demo {
def main(args: Array[String]): Unit = {
import dispatch._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.util.{Failure, Success}
val http = Http.configure { b => b }
val request = url("http://stackoverflow.com/").GET
val response = http(request OK as.String)
response onComplete {
case Success(content) =>
println(content)
case Failure(ex) =>
ex.printStackTrace()
}
}
}
Why is this happening, how can I debug this kind of issues?
I have read the Dispatch documentation (http://dispatch.databinder.net/Dispatch.html) but couldn't figure out the problem.
I suspect that this is in relation with the ExecutionContext and the Async calls / Futures.
Upvotes: 3
Views: 60