scalatestplus-play icon indicating copy to clipboard operation
scalatestplus-play copied to clipboard

BaseOneServerPerSuite swallows exception when stopping the server fails

Open stijn-vanbael-enprove opened this issue 2 years ago • 1 comments

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.

stijn-vanbael-enprove avatar Jul 11 '23 08:07 stijn-vanbael-enprove

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

mkurz avatar Jul 11 '23 08:07 mkurz