Skip to content

FutureAsyncHttpClientHandler hangs the application #26

Description

@alexeygolev

I'm probably doing something wrong or not doing something obvious. I'm playing around with sttp and I have a simple object extending the App trait that makes a call using FutureAsyncHttpClientHandler backend. It works and I'm getting a response. The problem is the app seems to hang and I can exit it with either System.exit or even providing a custom executor and then shutting it down.
I tried doing this

object MyApp {
  def main(args: Array[String]): Unit = {
    import java.util.concurrent.ForkJoinPool
    val executor = new ForkJoinPool()
    implicit val context = ExecutionContext.fromExecutor(executor)
   /* 
   Todo.run uses FutureAsyncHttpClientHandler backend and issues a simple http request 
   returning a Future. Todo.run has an implicit ExecutionContext obviously so the context 
   that I create is used 
  */
   val result = Await.result(Todo.run, 3 seconds)
    try {
      import java.util.concurrent.TimeUnit
      executor.shutdown()
      executor.awaitTermination(1, TimeUnit.MINUTES)
    } catch {
      case e: Exception => println("Something went wrong!")
    }
  }
}

But it didn't change anything

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions