{"record":{"id":"9c940ed2ba2b2631","repo":"apache/kafka","slug":"string-must-be-uppercase","errorCode":null,"errorMessage":"String must be UPPERCASE.","messagePattern":"String must be UPPERCASE\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"clients/src/main/java/org/apache/kafka/clients/admin/RaftVoterEndpoint.java","lineNumber":46,"sourceCode":"@InterfaceStability.Stable\n@InterfaceAudience.Public\npublic class RaftVoterEndpoint {\n    private final String listener;\n    private final String host;\n    private final int port;\n\n    private static String requireNonNullAllCapsNonEmpty(String input) {\n        if (input == null) {\n            throw new IllegalArgumentException(\"Null argument not allowed.\");\n        }\n        if (!input.trim().equals(input)) {\n            throw new IllegalArgumentException(\"Leading or trailing whitespace is not allowed.\");\n        }\n        if (input.isEmpty()) {\n            throw new IllegalArgumentException(\"Empty string is not allowed.\");\n        }\n        if (!input.toUpperCase(Locale.ROOT).equals(input)) {\n            throw new IllegalArgumentException(\"String must be UPPERCASE.\");\n        }\n        return input;\n    }\n\n    /**\n     * Create an endpoint for a metadata quorum voter.\n     *\n     * @param listener          The human-readable name for this endpoint. For example, CONTROLLER.\n     * @param host              The DNS hostname for this endpoint.\n     * @param port              The network port for this endpoint.\n     */\n    public RaftVoterEndpoint(\n        String listener,\n        String host,\n        int port\n    ) {\n        this.listener = requireNonNullAllCapsNonEmpty(listener);\n        this.host = Objects.requireNonNull(host);","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/apache/kafka/blob/996fb4585aa1bcc8980b0e1b8d6b168b986cd979/clients/src/main/java/org/apache/kafka/clients/admin/RaftVoterEndpoint.java#L28-L64","documentation":"Thrown by RaftVoterEndpoint.requireNonNullAllCapsNonEmpty when the listener string contains lowercase characters (input.toUpperCase(Locale.ROOT) != input). Kafka listener names are conventionally uppercase identifiers (CONTROLLER, BROKER, etc.) and the voter endpoint enforces this to prevent silent mismatches against broker listener definitions.","triggerScenarios":"Constructing `new RaftVoterEndpoint(\"controller\", host, port)` or any mixed-case/lowercase value such as \"Controller\". Triggered when code reads a listener name from a case-insensitive source.","commonSituations":"Lowercasing the value for storage and forgetting to re-uppercase; reading from a YAML config where lowercase was used stylistically; copying a listener name from a log line that was lowercased for display.","solutions":["Use the canonical uppercase listener name from your broker config (e.g. \"CONTROLLER\").","Uppercase the value programmatically before passing: `listener.toUpperCase(Locale.ROOT)` (but only if you're certain of the intended name).","Align the source config so listener names are written uppercase consistently."],"exampleFix":"// before\nnew RaftVoterEndpoint(\"controller\", host, port);\n\n// after\nnew RaftVoterEndpoint(\"CONTROLLER\", host, port);","handlingStrategy":"validation","validationCode":"String upper = listener == null ? null : listener.toUpperCase(Locale.ROOT);\nnew RaftVoterEndpoint(upper, host, port); // only if you are sure of the canonical name","typeGuard":"static boolean isUpperCaseIdentifier(String s) {\n    return s != null && !s.isEmpty() && s.trim().equals(s) && s.toUpperCase(Locale.ROOT).equals(s);\n}","tryCatchPattern":"try {\n    new RaftVoterEndpoint(listener, host, port);\n} catch (IllegalArgumentException e) {\n    log.error(\"Listener '{}' rejected: {}\", listener, e.getMessage());\n}","preventionTips":["Always write Kafka listener names uppercase in config files.","If your tooling lowercases keys, normalize listener names back to uppercase before use.","Add a config sanity check that fails fast on lowercase listener names."],"tags":["admin-client","kraft","raft-voter","validation","illegal-argument","naming"],"backgroundTag":null,"analyzedSha":"996fb4585aa1bcc8980b0e1b8d6b168b986cd979","analyzedAt":"2026-08-11T22:03:28.655Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}