I’m building an application based on Akka Cluster Sharding, under Play 2.7 (and thus Akka 2.5), using Classic Akka for now. (I’ll switch to Akka Typed in due course, probably after we can upgrade to Play 2.8, but for now it’s easier to build it in Classic.)
That’s all working nicely – the problem is when I run my tests. I’m building some fairly realistic Play API-level tests, which involve instantiating and running the components and the application largely for real, feeding inputs into them, and then shutting them down and moving on to the next test. This is the way I normally test, and it generally works well.
In this case, it’s working well for the first test, but when I try to run the second I’m getting:
org.jboss.netty.channel.ChannelException: Failed to bind to: localhost/127.0.0.1:2552
So the cluster channel obviously isn’t shutting down at the end of the first test – but I don’t understand why not. I’m calling CoordinatedShutdownProvider().get.run
at the end of each test, and that’s always done a good job of shutting Play down cleanly. It doesn’t seem to be releasing the remoting port, though.
Am I missing something? How do I tell the cluster to shut itself down properly, beyond what I’m already doing with CoordinatedShutdown?