@@ -402,9 +402,8 @@ private void dumpServerLog(String prefix, File out) throws IOException {
402402 }
403403
404404 private static int findFreePort () {
405- try (java .net .ServerSocket socket = new java .net .ServerSocket ()) {
405+ try (java .net .ServerSocket socket = new java .net .ServerSocket (0 )) {
406406 socket .setReuseAddress (true );
407- socket .bind (new java .net .InetSocketAddress ("127.0.0.1" , 0 ));
408407 return socket .getLocalPort ();
409408 } catch (java .io .IOException e ) {
410409 throw new RuntimeException ("Failed to find a free port" , e );
@@ -452,8 +451,8 @@ public String toString() {
452451 }
453452
454453 static final class Builder {
455- private static final String DEFAULT_BASE_URI = "http://localhost" ;
456- private static final String DEFAULT_GRPC_BASE_URI = "http://localhost" ;
454+ private static final String DEFAULT_BASE_URI = "http://localhost:9000 " ;
455+ private static final String DEFAULT_GRPC_BASE_URI = "http://localhost:9005 " ;
457456 private static final String DEFAULT_IMAGE_NAME ;
458457 private static final String DEFAULT_IMAGE_TAG ;
459458
@@ -505,13 +504,16 @@ static final class Builder {
505504 private String containerName ;
506505
507506 private Builder () {
508- this (
509- false ,
510- DEFAULT_BASE_URI + ":" + findFreePort (),
511- DEFAULT_GRPC_BASE_URI + ":" + findFreePort (),
512- DEFAULT_IMAGE_NAME ,
513- DEFAULT_IMAGE_TAG ,
514- DEFAULT_CONTAINER_NAME + "_" + java .util .UUID .randomUUID ().toString ().substring (0 , 8 ));
507+ int httpPort = findFreePort ();
508+ int grpcPort = findFreePort ();
509+ String uuid = java .util .UUID .randomUUID ().toString ().substring (0 , 8 );
510+
511+ this .ignorePullError = false ;
512+ this .baseUri = "http://127.0.0.1:" + httpPort ;
513+ this .gRPCBaseUri = "http://127.0.0.1:" + grpcPort ;
514+ this .dockerImageName = DEFAULT_IMAGE_NAME ;
515+ this .dockerImageTag = DEFAULT_IMAGE_TAG ;
516+ this .containerName = DEFAULT_CONTAINER_NAME + "_" + uuid ;
515517 }
516518
517519 private Builder (
0 commit comments