{"record":{"id":"5ba011d395e20009","repo":"aeron-io/aeron","slug":"port-must-be-an-integer-value-between-0-and-65535","errorCode":null,"errorMessage":":port must be an integer value between 0 and 65535","messagePattern":":port must be an integer value between 0 and 65535","errorType":"validation","errorClass":"NumberFormatException","httpStatus":null,"severity":"error","filePath":"aeron-driver/src/main/java/io/aeron/driver/media/WildcardPortManager.java","lineNumber":124,"sourceCode":"            return EMPTY_PORT_RANGE;\n        }\n\n        final String[] ports = value.split(\" +\");\n        if (ports.length != 2)\n        {\n            throw new IllegalArgumentException(\"port range \\\"\" + value + \"\\\" incorrect format\");\n        }\n\n        final int[] portRange = new int[2];\n\n        try\n        {\n            portRange[0] = Integer.parseUnsignedInt(ports[0]);\n            portRange[1] = Integer.parseUnsignedInt(ports[1]);\n\n            if (portRange[0] > 65535 || portRange[1] > 65535)\n            {\n                throw new NumberFormatException(value + \":port must be an integer value between 0 and 65535\");\n            }\n\n            if (portRange[0] > portRange[1])\n            {\n                throw new NumberFormatException(value + \":low port value must be lower than high port value\");\n            }\n        }\n        catch (final NumberFormatException ex)\n        {\n            throw new IllegalArgumentException(\"invalid port value \" + value, ex);\n        }\n\n        return portRange;\n    }\n\n    private int findOpenPort()\n    {\n        for (int i = nextPort; i <= highPort; i++)","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-driver/src/main/java/io/aeron/driver/media/WildcardPortManager.java#L106-L142","documentation":"WildcardPortManager.parsePortRange parses a 'low-high' port range string for wildcard port allocation. Both endpoints are parsed as unsigned integers, and if either exceeds 65535 a NumberFormatException with this message is thrown. The caller then rethrows it as an IllegalArgumentException ('invalid port value ...'), so developers typically see the wrapping message.","triggerScenarios":"Passing a port-range config value (e.g. aeron.driver.ports.range style '10000-65535') where one bound is a number greater than 65535, or a value that Integer.parseUnsignedInt rejects (negative or non-numeric), e.g. '70000-65535' or '0-99999'.","commonSituations":"Typos in driver configuration, copying an IPv6 port-like component, or assuming the range endpoint can exceed the 16-bit TCP/UDP limit; also occurs when range syntax uses wrong separators so parseUnsignedInt fails.","solutions":["Ensure both bounds of the range string are integers in 0-65535, e.g. '10000-20000'.","Verify the range string format is exactly '<low>-<high>' with a dash and no spaces or extra characters.","If you need ports above 65535, that is impossible for UDP/TCP; lower the configured range.","Catch IllegalArgumentException at configuration load time and report the offending value to the operator."],"exampleFix":"// before\nWildcardPortManager mgr = new WildcardPortManager(\"0-99999\", ...);\n// after\nWildcardPortManager mgr = new WildcardPortManager(\"0-65535\", ...);","handlingStrategy":"validation","validationCode":"long low = Long.parseLong(parts[0]); long high = Long.parseLong(parts[1]);\nif (low > 65535 || high > 65535) throw new IllegalArgumentException(\"port out of 0-65535: \" + value);","typeGuard":null,"tryCatchPattern":"try { new WildcardPortManager(value, ...); } catch (IllegalArgumentException e) { log.error(\"Bad port range {}: {}\", value, e.getMessage()); throw new ConfigException(e); }","preventionTips":["Validate range strings at config-load time, before driver construction","Keep bounds as constants: 0 and 65535","Use unit tests covering boundary values of your config parser"],"tags":["java","aeron-driver","configuration","port-range"],"backgroundTag":"value-out-of-range","analyzedSha":"6d60124e15e35c11b49ba2e3c2c2858a09a18803","analyzedAt":"2026-09-12T11:17:07.683Z","contentChangedAt":"2026-09-12T11:17:07.683Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}