facebook/swift — pull request #86 by andrewcox (2013-05-16 18:12:39+00:00)
Title: Fix occasional test failures from port conflicts

If tests are running concurrently, the code in ThriftServer was getting a random port by binding a ServerSocket to port 0, checking what actual port was bound, then unbinding it (so that the ThriftServer could bind it).

This caused a race condition where the random port that is chosen is then claimed by a different server in a different test. The fix is to bind the actual server startup to port 0. A side effect of this is that if you are binding to port 0, you won't be able to get the real port until the server starts.