diff --git a/s2a/src/test/java/io/grpc/s2a/internal/channel/S2AHandshakerServiceChannelTest.java b/s2a/src/test/java/io/grpc/s2a/internal/channel/S2AHandshakerServiceChannelTest.java index 16409721ff5..46f705d2f77 100644 --- a/s2a/src/test/java/io/grpc/s2a/internal/channel/S2AHandshakerServiceChannelTest.java +++ b/s2a/src/test/java/io/grpc/s2a/internal/channel/S2AHandshakerServiceChannelTest.java @@ -30,7 +30,6 @@ import io.grpc.StatusRuntimeException; import io.grpc.TlsChannelCredentials; import io.grpc.TlsServerCredentials; -import io.grpc.benchmarks.Utils; import io.grpc.internal.SharedResourceHolder.Resource; import io.grpc.netty.NettyServerBuilder; import io.grpc.stub.StreamObserver; @@ -123,7 +122,7 @@ public void getChannelResource_twoDistinctChannels() { InsecureChannelCredentials.create()); Resource resourceTwo = S2AHandshakerServiceChannel.getChannelResource( - "localhost:" + Utils.pickUnusedPort(), InsecureChannelCredentials.create()); + "localhost:" + plaintextServer.getPort() + 1, InsecureChannelCredentials.create()); assertThat(resourceTwo).isNotEqualTo(resource); } @@ -135,7 +134,7 @@ public void getChannelResource_mtlsTwoDistinctChannels() throws Exception { "localhost:" + mtlsServer.getPort(), getTlsChannelCredentials()); Resource resourceTwo = S2AHandshakerServiceChannel.getChannelResource( - "localhost:" + Utils.pickUnusedPort(), getTlsChannelCredentials()); + "localhost:" + mtlsServer.getPort() + 1, getTlsChannelCredentials()); assertThat(resourceTwo).isNotEqualTo(resource); } @@ -229,13 +228,13 @@ private static Server createMtlsServer() throws Exception { .clientAuth(TlsServerCredentials.ClientAuth.REQUIRE) .build(); return grpcCleanup.register( - NettyServerBuilder.forPort(Utils.pickUnusedPort(), creds).addService(service).build()); + NettyServerBuilder.forPort(0, creds).addService(service).build()); } private static Server createPlaintextServer() { SimpleServiceImpl service = new SimpleServiceImpl(); return grpcCleanup.register( - ServerBuilder.forPort(Utils.pickUnusedPort()).addService(service).build()); + ServerBuilder.forPort(0).addService(service).build()); } private static ChannelCredentials getTlsChannelCredentials() throws Exception {