3030import io .grpc .StatusRuntimeException ;
3131import io .grpc .TlsChannelCredentials ;
3232import io .grpc .TlsServerCredentials ;
33- import io .grpc .benchmarks .Utils ;
3433import io .grpc .internal .SharedResourceHolder .Resource ;
3534import io .grpc .netty .NettyServerBuilder ;
3635import io .grpc .stub .StreamObserver ;
@@ -123,7 +122,7 @@ public void getChannelResource_twoDistinctChannels() {
123122 InsecureChannelCredentials .create ());
124123 Resource <Channel > resourceTwo =
125124 S2AHandshakerServiceChannel .getChannelResource (
126- "localhost:" + Utils . pickUnusedPort () , InsecureChannelCredentials .create ());
125+ "localhost:" + plaintextServer . getPort () + 1 , InsecureChannelCredentials .create ());
127126 assertThat (resourceTwo ).isNotEqualTo (resource );
128127 }
129128
@@ -135,7 +134,7 @@ public void getChannelResource_mtlsTwoDistinctChannels() throws Exception {
135134 "localhost:" + mtlsServer .getPort (), getTlsChannelCredentials ());
136135 Resource <Channel > resourceTwo =
137136 S2AHandshakerServiceChannel .getChannelResource (
138- "localhost:" + Utils . pickUnusedPort () , getTlsChannelCredentials ());
137+ "localhost:" + mtlsServer . getPort () + 1 , getTlsChannelCredentials ());
139138 assertThat (resourceTwo ).isNotEqualTo (resource );
140139 }
141140
@@ -229,13 +228,13 @@ private static Server createMtlsServer() throws Exception {
229228 .clientAuth (TlsServerCredentials .ClientAuth .REQUIRE )
230229 .build ();
231230 return grpcCleanup .register (
232- NettyServerBuilder .forPort (Utils . pickUnusedPort () , creds ).addService (service ).build ());
231+ NettyServerBuilder .forPort (0 , creds ).addService (service ).build ());
233232 }
234233
235234 private static Server createPlaintextServer () {
236235 SimpleServiceImpl service = new SimpleServiceImpl ();
237236 return grpcCleanup .register (
238- ServerBuilder .forPort (Utils . pickUnusedPort () ).addService (service ).build ());
237+ ServerBuilder .forPort (0 ).addService (service ).build ());
239238 }
240239
241240 private static ChannelCredentials getTlsChannelCredentials () throws Exception {
0 commit comments