kaliber-scala / jira-exception-processor

Error reporting to Jira with fallback to email for Play
0 stars 1 forks source link

actorSystem isn't terminated after request #15

Open jorkzijlstra opened 7 years ago

jorkzijlstra commented 7 years ago

ActorSystem("jiraExceptionProcessor") is created but never terminated.

EECOLOR commented 7 years ago

What is your suggestion?

jorkzijlstra commented 7 years ago

Implement the following:

def withWsClient[T](code: WSClient => T): T = {
      val config = AhcWSClientConfig(wsClientConfig = defaultWsConfig)
      val builder = new AhcConfigBuilder(config)
      val ahcConfig = builder.configure().build()

      implicit val system: ActorSystem = ActorSystem("resourceApiLoadTest")
      implicit val materializer = ActorMaterializer()

      val wsClient = new AhcWSClient(ahcConfig)

      try code(wsClient)
      finally {
        wsClient.close()
        system.terminate()
      }
    }
EECOLOR commented 7 years ago

Ahh, I don't have time the next couple of weeks to add this, but feel free to do it yourself :smile:

jorkzijlstra commented 7 years ago

Really, no time for a couple of weeks to move 5 lines up in the scope and add 1. Luckily I was already going to change this myself and just created the issue as an marker.

EECOLOR commented 7 years ago

Haha, I see what you are saying and I totally agree that normally that would not be an issue. Thing is I wiped most of my drive and have no Scala tools on my machine and this is a change that I would certainly test. :smile:

jorkzijlstra commented 7 years ago

We will have to check what happens when 2 issues need to be created around the same time. I guess it might fail since the actorSystem will be shutdown after the first request.

EECOLOR commented 7 years ago

A new actor system is created for each call to the function. I don't think the name is significant, but if it is you can make it unique.