Fix minor logic error in SocketUtils

This commit is contained in:
Sam Brannen
2017-12-06 17:00:29 -08:00
parent 9f36d170be
commit 767ea9db83
2 changed files with 32 additions and 11 deletions

View File

@@ -258,12 +258,13 @@ public class SocketUtils {
int candidatePort;
int searchCounter = 0;
do {
if (searchCounter++ > portRange) {
if (searchCounter > portRange) {
throw new IllegalStateException(String.format(
"Could not find an available %s port in the range [%d, %d] after %d attempts",
name(), minPort, maxPort, searchCounter));
}
candidatePort = findRandomPort(minPort, maxPort);
searchCounter++;
}
while (!isPortAvailable(candidatePort));