aeron-io/aeron · error · NumberFormatException

:low port value must be lower than high port value

Error message

:low port value must be lower than high port value

What it means

parsePortRange also enforces ordering: after both bounds parse successfully, it requires portRange[0] <= portRange[1]. If the low bound is greater than the high bound, a NumberFormatException with this message is thrown, again wrapped by the caller into IllegalArgumentException 'invalid port value <value>'.

Solutions

  1. Swap the bounds so the range is 'low-high' ascending, e.g. '10000-20000'.
  2. Normalize the range in your config loader with Math.min/Math.max before passing it in.
  3. Validate the range at startup and fail fast with a clear message.
  4. Equal bounds ('5000-5000') are allowed; only strictly decreasing ranges fail.

Example fix

// before
WildcardPortManager mgr = new WildcardPortManager("20000-10000", ...);
// after
WildcardPortManager mgr = new WildcardPortManager("10000-20000", ...);
Defensive patterns

Strategy: validation

Validate before calling

if (low > high) throw new IllegalArgumentException("low must be <= high in range " + value);

Try / catch

try { new WildcardPortManager(value, ...); } catch (IllegalArgumentException e) { log.error("Invalid port range {}: {}", value, e.getMessage()); throw new ConfigException(e); }

Prevention

When it happens

Trigger: Configuring a wildcard port range with reversed bounds such as '20000-10000' where the low value exceeds the high value.

Common situations: Hand-edited configuration files, copy-paste of ranges in descending order, or programmatically generated ranges where min/max were swapped.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of aeron-io/aeron@6d60124e15 (2026-09-12). Data as JSON: /api/errors/ee08b3a82e0d4930. Report an issue: GitHub.

Appendix: source

Thrown at aeron-driver/src/main/java/io/aeron/driver/media/WildcardPortManager.java:129

        {
            throw new IllegalArgumentException("port range \"" + value + "\" incorrect format");
        }

        final int[] portRange = new int[2];

        try
        {
            portRange[0] = Integer.parseUnsignedInt(ports[0]);
            portRange[1] = Integer.parseUnsignedInt(ports[1]);

            if (portRange[0] > 65535 || portRange[1] > 65535)
            {
                throw new NumberFormatException(value + ":port must be an integer value between 0 and 65535");
            }

            if (portRange[0] > portRange[1])
            {
                throw new NumberFormatException(value + ":low port value must be lower than high port value");
            }
        }
        catch (final NumberFormatException ex)
        {
            throw new IllegalArgumentException("invalid port value " + value, ex);
        }

        return portRange;
    }

    private int findOpenPort()
    {
        for (int i = nextPort; i <= highPort; i++)
        {
            if (!portSet.contains(i))
            {
                return i;
            }

View on GitHub (pinned to 6d60124e15)