Closed franslundberg closed 6 years ago
Mentioning Peter: @peterskord .
Strange, but on jag box (Ubuntu, JVM 1.7), I always get exception when running:
f@ada:~/files/p/salt/salt-channel$ java -cp out/classes/:lib/* saltchannel.dev.TcpTestServer
Exception in thread "main" java.net.BindException: Address already in use
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376)
at java.net.ServerSocket.bind(ServerSocket.java:376)
at java.net.ServerSocket.<init>(ServerSocket.java:237)
at java.net.ServerSocket.<init>(ServerSocket.java:128)
at saltchannel.dev.TcpTestServer.start(TcpTestServer.java:75)
at saltchannel.dev.TcpTestServer.main(TcpTestServer.java:160)
Forget about the last comment, was due to opening the same port all the time.
Added unit tests for the class. Works fine to start()/stop() multiple times with the same port. Perhaps the tests of @peterskord opens the same port in another test?
Closing this. Cannot reproduce. Let's open again if needed and reproducible.
Ref: Peter Skörd,
Peter and that project is using a new TcpTestServer() multiple times within same process. Used for testing. Runs on build server.
Likely a "bug". However, saltchannel.dev.TcpTestServer was never intended as production code as indicated by package name and class name.