Bug 37149 SocketUtil.findUnusedLocalPort bug [JUnit]
org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/util/SocketUtil.java
private static final Random fgRandom= new Random(System.currentTimeMillis());
	/**
	 * Method that looks for an unused local port
	 * 
	 * @param searchFrom lower limit of port range
	 * @param searchTo upper limit of port range
	 */
	public static int findUnusedLocalPort(String host, int searchFrom, int searchTo) {
		for (int i= 0; i < 10; i++) {
			int port= getRandomPort(searchFrom, searchTo);
			try {
				new Socket(host, port);
			} catch (SocketException e) {
				return port;
			} catch (IOException e) {
			}
		}
		return -1;
	}
	
	private static int getRandomPort(int low, int high) {
		return (int)(fgRandom.nextFloat()*(high-low))+low;
	}
}