aeron-io/aeron · error · IllegalArgumentException

invalid subnet

Error message

invalid subnet: <s>

What it means

Thrown during InterfaceSearchAddress.getSubnet when the search-address string ends with a slash, leaving the subnet prefix empty (e.g. '10.0.0.1/'). The library cannot interpret an absent prefix after the delimiter. It surfaces via the subnetPrefix accessor.

Solutions

  1. Either remove the trailing slash to use the default subnet prefix, or supply an explicit prefix length such as '/24'
  2. Validate the address string format before passing it into the driver configuration
  3. Search config files/URIs for dangling '/' characters in interface specifications

Example fix

// before
"192.168.0.1:40456/"
// after
"192.168.0.1:40456/24"  // or "192.168.0.1:40456"
Defensive patterns

Strategy: validation

Validate before calling

// reject dangling subnet slash before use
static boolean validSubnetSpec(String s) {
    int i = s.lastIndexOf('/');
    return i < 0 || (i < s.length() - 1 && s.substring(i + 1).chars().allMatch(Character::isDigit));
}

Type guard

null

Try / catch

try {
    addr.subnetPrefix();
} catch (IllegalArgumentException e) {
    if (e.getMessage().startsWith("invalid subnet: ")) {
        // strip the trailing slash and retry with default prefix
    } else { throw e; }
}

Prevention

When it happens

Trigger: Configuring an interface search address like '192.168.0.1/' or '0.0.0.0:8080/' — a slash present but no digits following it.

Common situations: Hand-edited channel URI or driver config where the subnet prefix was deleted but the slash left behind; template configs with placeholders like 'host/port/' incompletely filled in.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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

Appendix: source

Thrown at aeron-driver/src/main/java/io/aeron/driver/media/InterfaceSearchAddress.java:173

        final String addressString = getAddress(addressAndPort, slashIndex, colonIndex, rightAngleBraceIndex);
        final InetAddress hostAddress = InetAddress.getByName(addressString);
        final int port = getPort(addressAndPort, slashIndex, colonIndex, rightAngleBraceIndex);
        final int defaultSubnetPrefix = hostAddress.getAddress().length * 8;
        final int subnetPrefix = getSubnet(addressAndPort, slashIndex, defaultSubnetPrefix);

        return new InterfaceSearchAddress(new InetSocketAddress(hostAddress, port), subnetPrefix);
    }

    private static int getSubnet(final String s, final int slashIndex, final int defaultSubnetPrefix)
    {
        if (slashIndex < 0)
        {
            return defaultSubnetPrefix;
        }
        else if (s.length() - 1 == slashIndex)
        {
            throw new IllegalArgumentException("invalid subnet: " + s);
        }

        final int subnetStringBegin = slashIndex + 1;

        return AsciiEncoding.parseIntAscii(s, subnetStringBegin, s.length() - subnetStringBegin);
    }

    private static int getPort(
        final String s, final int slashIndex, final int colonIndex, final int rightAngleBraceIndex)
    {
        if (colonIndex < 0 || rightAngleBraceIndex > colonIndex)
        {
            return 0;
        }
        else if (s.length() - 1 == colonIndex)
        {
            throw new IllegalArgumentException("invalid port: " + s);
        }

View on GitHub (pinned to 6d60124e15)