Created
March 15, 2017 22:06
-
-
Save timcharper/dc8e5b8b9a790852394d0fb78f2c016c to your computer and use it in GitHub Desktop.
demonstrates the https AbruptTerminationException issue (requires ammonite)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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