You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm sharing an instance of MainClassApplicationUnderTest (or rather a subclass of it, to expose the server start call) between all test case methods in a JUnit 4 test class. This works fine, but when I add a second test class, the Ratpack server started by the first test class is still bound to the port specified and the following is thrown:
Caused by: java.net.BindException: Address already in use: bind
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:433)
at sun.nio.ch.Net.bind(Net.java:425)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:132)
at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:551)
at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1332)
at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:503)
at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:488)
at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:984)
at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:247)
at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:355)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:416)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:515)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:918)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at ratpack.exec.internal.DefaultExecController$ExecControllerBindingThreadFactory.lambda$newThread$0(DefaultExecController.java:137)
Interestingly, this only happens when running via Maven/Surefire. Running my full test suite in Intellij works fine. But then Intellij does its own weird stuff when running tests.
I'm sharing an instance of
MainClassApplicationUnderTest
(or rather a subclass of it, to expose the server start call) between all test case methods in a JUnit 4 test class. This works fine, but when I add a second test class, the Ratpack server started by the first test class is still bound to the port specified and the following is thrown:Interestingly, this only happens when running via Maven/Surefire. Running my full test suite in Intellij works fine. But then Intellij does its own weird stuff when running tests.
Code is as follows:
I'm using Ratpack 1.7.2
The text was updated successfully, but these errors were encountered: