Class AvailablePortFinder


  • public final class AvailablePortFinder
    extends Object
    Finds currently available server ports.
    • Method Detail

      • getNextAvailable

        public static int getNextAvailable()
        Gets the next available port.
        Returns:
        the available port
        Throws:
        IllegalStateException - if there are no ports available
      • reserveNetworkPorts

        public static Map<String,​Integer> reserveNetworkPorts​(String... names)
        Reserve a list of random and not in use network ports and place them in Map.
      • reserveNetworkPorts

        public static <T> Map<String,​T> reserveNetworkPorts​(Function<Integer,​T> converter,
                                                                  String... names)
        Reserve a list of random and not in use network ports and place them in Map.