apache/kafka · error · IllegalArgumentException
Null argument not allowed.
Error message
Null argument not allowed.
What it means
Thrown by RaftVoterEndpoint's internal validator requireNonNullAllCapsNonEmpty when an input string (the listener name) is null. RaftVoterEndpoint describes a single voter's network endpoint for KRaft quorum operations (add/remove voter). The listener name must match a configured broker listener name, which by Kafka convention are uppercase identifiers like CONTROLLER.
Source
Thrown at clients/src/main/java/org/apache/kafka/clients/admin/RaftVoterEndpoint.java:37
import org.apache.kafka.common.annotation.InterfaceAudience;
import org.apache.kafka.common.annotation.InterfaceStability;
import java.util.Locale;
import java.util.Objects;
/**
* 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.View on GitHub (pinned to 996fb4585a)
Solutions
- Supply a non-null listener name matching a configured listener (e.g. "CONTROLLER").
- If sourcing from config, default to the controller listener name explicitly: `props.getProperty("listener", "CONTROLLER")`.
- Add a null check upstream of the constructor call.
Example fix
// before new RaftVoterEndpoint(listenerName, host, port); // after String name = Objects.requireNonNull(listenerName, "listener name"); new RaftVoterEndpoint(name, host, port);
Defensive patterns
Strategy: validation
Validate before calling
String name = Objects.requireNonNull(listenerName, "listener name must not be null"); new RaftVoterEndpoint(name, host, port);
Type guard
static String requireListener(String s) {
if (s == null) throw new IllegalArgumentException("listener is null");
return s;
} Try / catch
try {
endpoint = new RaftVoterEndpoint(listener, host, port);
} catch (IllegalArgumentException e) {
throw new ConfigurationException("Invalid raft voter endpoint: " + e.getMessage(), e);
} Prevention
- Source listener names only from broker config (which guarantees non-null) or validate at the config-loading boundary.
- Keep a constant for the controller listener name rather than passing strings around.
- Add an integration test that builds a RaftVoterEndpoint from your config loader.
When it happens
Trigger: Constructing `new RaftVoterEndpoint(null, host, port)` or passing null as the listener argument to addVoter/removeVoter RPC building paths.
Common situations: Loading voter configuration from a property file where the listener key is absent; passing a value derived from a missing Optional without fallback; programmatic voter management where the listener name is computed but unset.
Related errors
- Leading or trailing whitespace is not allowed.
- Empty string 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/ebe087bd653c5dd6.
Report an issue: GitHub.