Skip to content

Instantly share code, notes, and snippets.

@timcharper
Created March 15, 2017 22:06
Show Gist options
  • Save timcharper/dc8e5b8b9a790852394d0fb78f2c016c to your computer and use it in GitHub Desktop.
Save timcharper/dc8e5b8b9a790852394d0fb78f2c016c to your computer and use it in GitHub Desktop.
demonstrates the https AbruptTerminationException issue (requires ammonite)
#!/usr/bin/env amm
import $ivy.`com.typesafe.akka::akka-http:10.0.4`
import akka.actor._
import akka.http.scaladsl.Http
import akka.http.scaladsl.model.{ HttpRequest, Uri }
import akka.stream._
import scala.concurrent.duration._
import scala.concurrent.Await
import scala.util.control.NonFatal
implicit val system = ActorSystem("Test")
implicit val materializer = ActorMaterializer()
try {
val thing = Http().singleRequest(HttpRequest(uri = Uri("https://twitter.com")))
val result = Await.result(thing, 10.seconds)
println(s"got result ${result.status}")
// if we sleep then we do not see the exception
// Thread.sleep(10000)
} catch {
case NonFatal(ex) =>
println(s"ERROR: ${ex.getMessage}")
ex.printStackTrace(System.out)
} finally {
Await.result(Http().shutdownAllConnectionPools(), Duration.Inf)
materializer.shutdown()
// materializer.shutdown()
system.terminate()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment