{"record":{"id":"5d5adfd68d8b6ee3","repo":"quarkusio/quarkus","slug":"invalid-port-number-5d5adf","errorCode":null,"errorMessage":"Invalid port number","messagePattern":"Invalid port number","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/resteasy-reactive/rest-client/runtime/src/main/java/io/quarkus/rest/client/reactive/runtime/RestClientBuilderImpl.java","lineNumber":232,"sourceCode":"    @Override\n    public RestClientBuilderImpl hostnameVerifier(HostnameVerifier hostnameVerifier) {\n        clientBuilder.hostnameVerifier(hostnameVerifier);\n        return this;\n    }\n\n    @Override\n    public RestClientBuilderImpl followRedirects(final boolean follow) {\n        this.followRedirects = follow;\n        return this;\n    }\n\n    @Override\n    public RestClientBuilderImpl proxyAddress(final String proxyHost, final int proxyPort) {\n        if (proxyHost == null) {\n            throw new IllegalArgumentException(\"proxyHost must not be null\");\n        }\n        if ((proxyPort <= 0 || proxyPort > 65535) && !proxyHost.equals(\"none\")) {\n            throw new IllegalArgumentException(\"Invalid port number\");\n        }\n        this.proxyHost = proxyHost;\n        this.proxyPort = proxyPort;\n\n        return this;\n    }\n\n    public RestClientBuilderImpl proxyPassword(String proxyPassword) {\n        this.proxyPassword = proxyPassword;\n        return this;\n    }\n\n    public RestClientBuilderImpl proxyUser(String proxyUser) {\n        this.proxyUser = proxyUser;\n        return this;\n    }\n\n    public RestClientBuilderImpl nonProxyHosts(String nonProxyHosts) {","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/resteasy-reactive/rest-client/runtime/src/main/java/io/quarkus/rest/client/reactive/runtime/RestClientBuilderImpl.java#L214-L250","documentation":"proxyAddress(String, int) validates that the port is within 1–65535. An out-of-range port throws IllegalArgumentException 'Invalid port number', unless the host is the special value \"none\" used to disable proxying. This mirrors standard socket port validation.","triggerScenarios":"Calling builder.proxyAddress(host, 0), negative ports, or ports above 65535 (e.g. int overflow or a misparsed value); passing a placeholder port with host \"none\" is exempted.","commonSituations":"Parsing a port string that lost digits or was concatenated incorrectly; config holding 0 as 'default'; using an unsigned-port value >65535 from a bad calculation; forgetting that proxyAddress(host, 0) is invalid even as a 'no proxy' sentinel — \"none\" is the sentinel.","solutions":["Pass a valid port in the 1–65535 range","Use proxyAddress(\"none\", arbitraryPort) to disable the proxy instead of port 0","Validate/parse the port from config with Integer.parseInt and range-check before calling"],"exampleFix":"// before\nbuilder.proxyAddress(\"proxy.corp.com\", 0);\n// after\nbuilder.proxyAddress(\"proxy.corp.com\", 8080);","handlingStrategy":"validation","validationCode":"static void requireValidPort(int port) {\n    if (port <= 0 || port > 65535) throw new IllegalArgumentException(\"Port out of range: \" + port);\n}\n// call before builder.proxyAddress(host, port)","typeGuard":"static boolean isValidPort(int p) { return p > 0 && p <= 65535; }","tryCatchPattern":"try {\n    builder.proxyAddress(host, port);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().equals(\"Invalid port number\")) {\n        throw new IllegalArgumentException(\"Proxy port must be 1-65535, got: \" + port);\n    }\n    throw e;\n}","preventionTips":["Range-check parsed port values before passing them to the builder","Use \"none\" host rather than port 0 to disable proxying","Log the raw port string when parsing config so truncation/typos are visible"],"tags":["rest-client","proxy","port-validation"],"backgroundTag":"invalid-port-number","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}