private void startRelayWithPortTollerance ( HttpServer server , SslListener relay , int tries ) throws Exception { if ( tries >= 5 ) { throw new BindException ( "Unable to bind to several ports, most recently " + relay . getPort ( ) + ". Giving up" ) ; } try { if ( server . isStarted ( ) ) { relay . start ( ) ; } else { throw new RuntimeException ( "Can't start SslRelay: server is not started (perhaps it was just shut down?)" ) ; } } catch ( BindException e ) { // doh - the port is being used up, let's pick a new port LOG . info ( "Unable to bind to port %d, going to try port %d now" , relay . getPort ( ) , relay . getPort ( ) + 1 ) ; relay . setPort ( relay . getPort ( ) + 1 ) ; startRelayWithPortTollerance ( server , relay , tries + 1 ) ; } }
END ODO CHANGES