Validate configuration dependencies and constraints at initialization time rather than allowing invalid combinations to cause runtime failures. When configurations have interdependencies, implement validation logic that checks these relationships early and provides clear error messages.
Validate configuration dependencies and constraints at initialization time rather than allowing invalid combinations to cause runtime failures. When configurations have interdependencies, implement validation logic that checks these relationships early and provides clear error messages.
Key practices:
KafkaConfig
should validate that quorum.auto.join.enable
is only true when process.role
contains controller
)CommandLineUtils.checkRequiredArgs()
but delegate validation to specialized methods when possibleExample from the discussions:
// In KafkaConfig validation
public static final String QUORUM_AUTO_JOIN_ENABLE = QUORUM_PREFIX + "auto.join.enable";
public static final boolean DEFAULT_QUORUM_AUTO_JOIN_ENABLE = false;
// Validation should ensure this is only true when process.role contains controller
if (autoJoinEnabled && !processRoles.contains("controller")) {
throw new ConfigException("quorum.auto.join.enable can only be true when process.role contains controller");
}
This approach prevents configuration-related runtime errors and makes system requirements explicit and discoverable during setup rather than during operation.
Enter the URL of a public GitHub repository