This is an automated email from the ASF dual-hosted git repository. dlmarion pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/main by this push: new 87a715a Modified ZooKeepterTestingServer to use PortUtils for finding a ZK port (#2485) 87a715a is described below commit 87a715a4eace9bbd2a04f9accdf986fd4029d46d Author: Dave Marion <dlmar...@apache.org> AuthorDate: Thu Feb 10 13:53:06 2022 -0500 Modified ZooKeepterTestingServer to use PortUtils for finding a ZK port (#2485) Closes #2474 --- .../accumulo/test/zookeeper/ZooKeeperTestingServer.java | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/test/src/main/java/org/apache/accumulo/test/zookeeper/ZooKeeperTestingServer.java b/test/src/main/java/org/apache/accumulo/test/zookeeper/ZooKeeperTestingServer.java index 331dc68..b615c6e 100644 --- a/test/src/main/java/org/apache/accumulo/test/zookeeper/ZooKeeperTestingServer.java +++ b/test/src/main/java/org/apache/accumulo/test/zookeeper/ZooKeeperTestingServer.java @@ -18,13 +18,12 @@ */ package org.apache.accumulo.test.zookeeper; -import static org.apache.accumulo.harness.AccumuloITBase.random; - import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.concurrent.CountDownLatch; +import org.apache.accumulo.server.util.PortUtils; import org.apache.curator.test.TestingServer; import org.apache.zookeeper.CreateMode; import org.apache.zookeeper.Watcher; @@ -49,7 +48,7 @@ public class ZooKeeperTestingServer implements AutoCloseable { * client connections. It will try three times, with a 5 second pause to connect. */ public ZooKeeperTestingServer() { - this(getPort()); + this(PortUtils.getRandomFreePort()); } private ZooKeeperTestingServer(int port) { @@ -94,18 +93,6 @@ public class ZooKeeperTestingServer implements AutoCloseable { } - /** - * Returns an random integer between 50_000 and 65_000 (typical ephemeral port range for linux is - * listed as 49,152 to 65,535 - * - * @return a random port with the linux ephemeral port range. - */ - private static int getPort() { - final int minPort = 50_000; - final int maxPort = 65_000; - return random.nextInt((maxPort - minPort) + 1) + minPort; - } - public ZooKeeper getZooKeeper() { return zoo; }