{"record":{"id":"ce2ffe1960d51f4a","repo":"aeron-io/aeron","slug":"no-port-specified-on-resolvedendpoint-resolvedendpoint","errorCode":null,"errorMessage":"No port specified on resolvedEndpoint=<resolvedEndpoint>","messagePattern":"No port specified on resolvedEndpoint=<resolvedEndpoint>","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"aeron-client/src/main/java/io/aeron/ChannelUri.java","lineNumber":618,"sourceCode":"        return uri;\n    }\n\n    /**\n     * Uses the supplied endpoint to resolve any wildcard ports. If the existing endpoint has a value of \"0\" for then\n     * the port of this endpoint will be used instead. If the endpoint is not specified in this uri, then the whole\n     * supplied endpoint is used. If the endpoint exists and has a non-wildcard port, then the existing endpoint is\n     * retained.\n     *\n     * @param resolvedEndpoint The endpoint to supply a resolved endpoint port.\n     * @throws IllegalArgumentException if the supplied resolvedEndpoint does not have a port or the port is zero.\n     * @throws NullPointerException     if the supplied resolvedEndpoint is null\n     */\n    public void replaceEndpointWildcardPort(final String resolvedEndpoint)\n    {\n        final int portSeparatorIndex = requireNonNull(resolvedEndpoint, \"resolvedEndpoint is null\").lastIndexOf(':');\n        if (-1 == portSeparatorIndex)\n        {\n            throw new IllegalArgumentException(\"No port specified on resolvedEndpoint=\" + resolvedEndpoint);\n        }\n        if (resolvedEndpoint.endsWith(\":0\"))\n        {\n            throw new IllegalArgumentException(\"Wildcard port specified on resolvedEndpoint=\" + resolvedEndpoint);\n        }\n\n        final String existingEndpoint = get(ENDPOINT_PARAM_NAME);\n        if (null == existingEndpoint)\n        {\n            put(ENDPOINT_PARAM_NAME, resolvedEndpoint);\n        }\n        else if (existingEndpoint.endsWith(\":0\"))\n        {\n            final String endpoint = existingEndpoint.substring(0, existingEndpoint.length() - 2) +\n                resolvedEndpoint.substring(resolvedEndpoint.lastIndexOf(':'));\n            put(ENDPOINT_PARAM_NAME, endpoint);\n        }\n    }","sourceCodeStart":600,"sourceCodeEnd":636,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-client/src/main/java/io/aeron/ChannelUri.java#L600-L636","documentation":"ChannelUri.replaceEndpointWildcardPort() substitutes the wildcard endpoint of the channel with a concrete resolved endpoint. It requires the resolvedEndpoint string to contain a ':' separating host and port; if none is found it throws IllegalArgumentException.","triggerScenarios":"Calling replaceEndpointWildcardPort() with a resolvedEndpoint lacking a port, e.g. \"192.168.1.10\" or \"myhost\" instead of \"192.168.1.10:40456\". Observed in tests replay, shouldThrowIfResolvedEndpointInvalid, assertSubstitution, liveLogRecord.","commonSituations":"Resolution code that returns only the hostname (e.g. from DNS/InetAddress.getHostName()) without appending the port; log/recorded endpoints printed without port then fed back.","solutions":["Ensure the resolved endpoint string includes the port (host:port) before calling replaceEndpointWildcardPort","Derive it from InetSocketAddress and use toString() so host and port are both present","Guard before calling: check the string contains ':' and reject otherwise"],"exampleFix":"// before\npublication.replaceEndpointWildcardPort(addr.getHostName()); // no port\n// after\nInetSocketAddress addr = ...;\npublication.replaceEndpointWildcardPort(addr.getHostString() + \":\" + addr.getPort());","handlingStrategy":"validation","validationCode":"static void requireHostPort(String resolvedEndpoint) {\n    if (resolvedEndpoint == null || resolvedEndpoint.lastIndexOf(':') < 0) {\n        throw new IllegalArgumentException(\"resolvedEndpoint must be host:port, got: \" + resolvedEndpoint);\n    }\n}","typeGuard":"static boolean hasPort(String endpoint) {\n    int i = endpoint == null ? -1 : endpoint.lastIndexOf(':');\n    return i > 0 && i < endpoint.length() - 1 && endpoint.substring(i + 1).chars().allMatch(Character::isDigit);\n}","tryCatchPattern":"try {\n    channelUri.replaceEndpointWildcardPort(resolvedEndpoint);\n} catch (IllegalArgumentException e) {\n    log.error(\"Bad resolved endpoint '{}'\", resolvedEndpoint, e);\n    throw new IllegalArgumentException(\"resolvedEndpoint must include a port\", e);\n}","preventionTips":["Always derive the resolved endpoint from the bound InetSocketAddress (host + port)","Never feed a bare hostname or DNS-only name into replaceEndpointWildcardPort","Assert host:port format in a unit test before wiring it into channel setup"],"tags":["endpoint","port","aeron"],"backgroundTag":"invalid-argument-format","analyzedSha":"6d60124e15e35c11b49ba2e3c2c2858a09a18803","analyzedAt":"2026-09-12T11:17:07.683Z","contentChangedAt":"2026-09-12T11:17:07.683Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}