apache/kafka · error · IllegalArgumentException
String must be UPPERCASE.
Error message
String must be UPPERCASE.
What it means
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.
Source
Thrown at clients/src/main/java/org/apache/kafka/clients/admin/RaftVoterEndpoint.java:46
@InterfaceStability.Stable
@InterfaceAudience.Public
public class RaftVoterEndpoint {
private final String listener;
private final String host;
private final int port;
private static String requireNonNullAllCapsNonEmpty(String input) {
if (input == null) {
throw new IllegalArgumentException("Null argument not allowed.");
}
if (!input.trim().equals(input)) {
throw new IllegalArgumentException("Leading or trailing whitespace is not allowed.");
}
if (input.isEmpty()) {
throw new IllegalArgumentException("Empty string is not allowed.");
}
if (!input.toUpperCase(Locale.ROOT).equals(input)) {
throw new IllegalArgumentException("String must be UPPERCASE.");
}
return input;
}
/**
* Create an endpoint for a metadata quorum voter.
*
* @param listener The human-readable name for this endpoint. For example, CONTROLLER.
* @param host The DNS hostname for this endpoint.
* @param port The network port for this endpoint.
*/
public RaftVoterEndpoint(
String listener,
String host,
int port
) {
this.listener = requireNonNullAllCapsNonEmpty(listener);
this.host = Objects.requireNonNull(host);View on GitHub (pinned to 996fb4585a)
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.
Example fix
// before
new RaftVoterEndpoint("controller", host, port);
// after
new RaftVoterEndpoint("CONTROLLER", host, port); Defensive patterns
Strategy: validation
Validate before calling
String upper = listener == null ? null : listener.toUpperCase(Locale.ROOT); new RaftVoterEndpoint(upper, host, port); // only if you are sure of the canonical name
Type guard
static boolean isUpperCaseIdentifier(String s) {
return s != null && !s.isEmpty() && s.trim().equals(s) && s.toUpperCase(Locale.ROOT).equals(s);
} Try / catch
try {
new RaftVoterEndpoint(listener, host, port);
} catch (IllegalArgumentException e) {
log.error("Listener '{}' rejected: {}", listener, e.getMessage());
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Null argument not allowed.
- Leading or trailing whitespace is not allowed.
- Empty string is not allowed.
- Cannot create a new partition reassignment without any repli
- Invalid empty members has been provided
AI-assisted analysis of apache/kafka@996fb4585a (2026-08-11).
Data as JSON: /api/errors/9c940ed2ba2b2631.
Report an issue: GitHub.