Horea Popa
Horea Popa

Reputation: 70

Scala/Dispatch program isn't terming

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

Answers (1)

Jay
Jay

Reputation: 1097

You just need to call

Http.shutdown()

Upvotes: 0

Related Questions