{"record":{"id":"758b4ea673f67f88","repo":"aeron-io/aeron","slug":"wildcard-port-specified-on-resolvedendpoint-resolvedendpoint","errorCode":null,"errorMessage":"Wildcard port specified on resolvedEndpoint=<resolvedEndpoint>","messagePattern":"Wildcard port specified on resolvedEndpoint=<resolvedEndpoint>","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"aeron-client/src/main/java/io/aeron/ChannelUri.java","lineNumber":622,"sourceCode":"     * 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    }\n\n    /**\n     * Call consumer for each parameter defined in the URI.\n     *","sourceCodeStart":604,"sourceCodeEnd":640,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-client/src/main/java/io/aeron/ChannelUri.java#L604-L640","documentation":"replaceEndpointWildcardPort() exists to replace a wildcard port (endpoint ending in ':0') with the actually bound port. If the resolvedEndpoint itself still has wildcard port ':0', there is nothing concrete to substitute, so it throws IllegalArgumentException.","triggerScenarios":"Calling replaceEndpointWildcardPort() with a resolvedEndpoint ending in \":0\", e.g. \"localhost:0\" — typically because the caller passed the original (unresolved) channel endpoint instead of the resolved local socket address.","commonSituations":"Reusing the publication's original URI endpoint rather than the locally bound address from LocalSocketAddress; passing a not-yet-resolved wildcard configuration through by mistake.","solutions":["Pass the actual resolved local address of the bound channel (e.g. from publication localSocketAddresses / subscription LocalSocketAddress), not the wildcard config","Check with endsWith(\":0\") before calling and skip or fail fast with a clear message","Ensure the transport has fully bound before reading the resolved endpoint"],"exampleFix":"// before\npublication.replaceEndpointWildcardPort(\"localhost:0\"); // still wildcard\n// after\nString resolved = publication.localSocketAddresses()[0].getHostString() + \":\" +\n    publication.localSocketAddresses()[0].getPort();\npublication.replaceEndpointWildcardPort(resolved);","handlingStrategy":"validation","validationCode":"static void requireNonWildcard(String resolvedEndpoint) {\n    if (resolvedEndpoint == null || resolvedEndpoint.endsWith(\":0\")) {\n        throw new IllegalArgumentException(\"resolvedEndpoint must have a concrete port: \" + resolvedEndpoint);\n    }\n}","typeGuard":"static boolean isConcretePort(String endpoint) {\n    int i = endpoint == null ? -1 : endpoint.lastIndexOf(':');\n    return i > 0 && !endpoint.substring(i + 1).equals(\"0\");\n}","tryCatchPattern":"try {\n    channelUri.replaceEndpointWildcardPort(resolvedEndpoint);\n} catch (IllegalArgumentException e) {\n    log.error(\"Wildcard port not resolved: {}\", resolvedEndpoint, e);\n    throw new IllegalStateException(\"Endpoint was not resolved before substitution\", e);\n}","preventionTips":["Pass the actual bound local address (e.g. from localSocketAddresses()), not the original wildcard config","Ensure the media driver has bound the transport before reading the resolved port","Skip substitution (or fail fast) when the resolved port is still 0"],"tags":["endpoint","port","wildcard","aeron"],"backgroundTag":"invalid-argument-value","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"}