rackerlabs/gdeproxy — pull request #28 by izrik (2013-09-03 16:50:57+00:00)
Title: Improve port finder

Previously, PortFinder used groovy's URL.getText() method to check if a port was open or not. This has certain problems, in that it involves an entire HTTP request/response pair, when all we really need is to know is if the port is in use or not. If an HTTP server happens to be listening on a port, and returns an error response, the getText method will throw an exception, which is not what we want. Rather, in that situation we would want to recognize only that the port is in use.

This pull request fixes the port search procedure by simply trying to connect a socket to a port, rather than making an HTTP request. That should make things less flaky. This pull request also adds tests for PortFinder, which were previously lacking.