Support identical minPort and maxPort in SocketUtils (#1612)

This commit fixes a bug where an IllegalStateException was
thrown if the minPort and maxPort values supplied to
SocketUtils.findAvailableTcpPort(int, int) were identical.
This commit is contained in:
Tony Mitchell
2017-12-06 16:38:46 -08:00
committed by Sam Brannen
parent f9689dfe48
commit 9f36d170be
2 changed files with 8 additions and 1 deletions

View File

@@ -258,7 +258,7 @@ 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));