assaabloy-ppi / salt-channel

The specification and the reference implementation of Salt Channel - a simple, light-weight secure channel protocol based on TweetNaCl by Bernstein.
MIT License
14 stars 11 forks source link

Does TcpTestServer close port correctly? #18

Closed franslundberg closed 6 years ago

franslundberg commented 6 years ago

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.

franslundberg commented 6 years ago

Mentioning Peter: @peterskord .

franslundberg commented 6 years ago

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)
franslundberg commented 6 years ago

Forget about the last comment, was due to opening the same port all the time.

franslundberg commented 6 years ago

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?

franslundberg commented 6 years ago

Closing this. Cannot reproduce. Let's open again if needed and reproducible.