apache/kafka · error · IllegalArgumentException
Empty string is not allowed.
Error message
Empty string is not allowed.
What it means
Thrown by RaftVoterEndpoint.requireNonNullAllCapsNonEmpty when the listener string is the empty string "". An empty listener name cannot correspond to any endpoint, so the constructor rejects it. Note this check runs after the whitespace check, so a value of just spaces will trip the whitespace branch first.
Source
Thrown at clients/src/main/java/org/apache/kafka/clients/admin/RaftVoterEndpoint.java:43
/**
* An endpoint for a raft quorum voter.
*/
@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 portView on GitHub (pinned to 996fb4585a)
Solutions
- Provide a real listener name such as "CONTROLLER".
- When loading config, treat empty as missing and fall back to a sensible default.
- Validate non-empty before constructing: `if (listener == null || listener.isEmpty()) throw ...`.
Example fix
// before
String listener = props.getProperty("listener", "");
new RaftVoterEndpoint(listener, host, port);
// after
String listener = props.getProperty("listener", "CONTROLLER");
new RaftVoterEndpoint(listener, host, port); Defensive patterns
Strategy: validation
Validate before calling
if (listener == null || listener.isEmpty()) {
throw new IllegalArgumentException("listener name required");
}
new RaftVoterEndpoint(listener, host, port); Type guard
static String requireNonEmptyListener(String s) {
if (s == null || s.isEmpty()) throw new IllegalArgumentException("listener empty");
return s;
} Try / catch
try {
new RaftVoterEndpoint(listener, host, port);
} catch (IllegalArgumentException e) {
throw new IllegalStateException("Voter config invalid: " + e.getMessage(), e);
} Prevention
- Default listener name to a constant ("CONTROLLER") when reading config.
- Reject empty config values at the config-loading boundary.
- Validate the full voter descriptor before issuing addVoter calls.
When it happens
Trigger: Constructing `new RaftVoterEndpoint("", host, port)`; reading a listener name from a config key that exists but has an empty value.
Common situations: Properties file with `listener.name=` (no value); JSON config with "listener": ""; defaulting a missing key to empty string instead of a real default.
Related errors
- Null argument not allowed.
- Leading or trailing whitespace is not allowed.
- String must be UPPERCASE.
- 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/41525ddee3c6a6ed.
Report an issue: GitHub.