Index: hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/MiniZooKeeperCluster.java =================================================================== --- hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/MiniZooKeeperCluster.java (revision 1522744) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/MiniZooKeeperCluster.java (working copy) @@ -134,7 +134,8 @@ /** * @param baseDir * @param numZooKeeperServers - * @return ClientPort server bound to. + * @return ClientPort server bound to, -1 if there was a + * binding problem and we couldn't pick another port. * @throws IOException * @throws InterruptedException */ @@ -169,7 +170,9 @@ 1000)); } catch (BindException e) { LOG.debug("Failed binding ZK Server to client port: " + - tentativePort); + tentativePort, e); + // We're told to use some port but it's occupied, fail + if (defaultClientPort > 0) return -1; // This port is already in use, try to use another. tentativePort = selectClientPort(); continue;