playframework / scalatestplus-play

ScalaTest + Play
https://www.playframework.com/documentation/latest/ScalaTestingWithScalaTest
Apache License 2.0
110 stars 61 forks source link

BaseOneServerPerSuite swallows exception when stopping the server fails #431

Open stijn-vanbael-enprove opened 1 year ago

stijn-vanbael-enprove commented 1 year ago

BaseOneServerPerSuite.run lines 168-172 read:

} catch { // In case the suite aborts, ensure the server is stopped
  case ex: Throwable =>
    runningServer.stopServer.close()
    throw ex
}

When runningServer.stopServer.close() throws another exception for any reason, the original exception is completely swallowed. This happens for example when new GuiceApplicationBuilder().configure(config).build() is called with a config property that has a different type than in application.conf. The application fails to start, the implicit lazy val app in BaseOneServerPerSuite is not initialized. runningServer.stopServer.close() tries to access and thus initialize app again, but Akka is already bound to port 25520, and the application fails to start because of a java.net.BindException.

mkurz commented 1 year ago

@stijn-vanbael-enprove A pull request with a fix would be highly appreciated, thanks!