alibaba/druid · error · IllegalArgumentException
Config DataSource error.
Error message
Config DataSource error.
What it means
Thrown when DruidDataSourceFactory.config(dataSource, configFileProperties) raises a SQLException while applying the properties loaded from the remote/file config to the DruidDataSource. The config step sets url, username, driver, pool sizing, etc.; a SQLException here means one of those properties was rejected (invalid value, parse failure, or a setter throwing). It is wrapped as IllegalArgumentException to fail datasource init fast.
Source
Thrown at core/src/main/java/com/alibaba/druid/filter/config/ConfigFilter.java:134
// 判断是否需要解密,如果需要就进行解密行动
boolean decrypt = isDecrypt(connectionProperties, configFileProperties);
if (configFileProperties == null) {
if (decrypt) {
decrypt(dataSource, null);
}
return;
}
if (decrypt) {
decrypt(dataSource, configFileProperties);
}
try {
DruidDataSourceFactory.config(dataSource, configFileProperties);
} catch (SQLException e) {
throw new IllegalArgumentException("Config DataSource error.", e);
}
}
public boolean isDecrypt(Properties connectionProperties, Properties configFileProperties) {
String decrypterId = connectionProperties.getProperty(CONFIG_DECRYPT);
if (decrypterId == null || decrypterId.length() == 0) {
if (configFileProperties != null) {
decrypterId = configFileProperties.getProperty(CONFIG_DECRYPT);
}
}
if (decrypterId == null || decrypterId.length() == 0) {
decrypterId = System.getProperty(SYS_PROP_CONFIG_DECRYPT);
}
return Boolean.valueOf(decrypterId);
}
View on GitHub (pinned to fa8dc99126)
Solutions
- Read IllegalArgumentException.getCause() (the SQLException) - its message names the offending property.
- Validate every key in the config file against DruidDataSourceFactory's accepted property names.
- Correct or remove the offending property and reload.
Defensive patterns
Strategy: validation
Validate before calling
// Pre-validate the config file's property values before init:
Properties p = loadConfig(configFilePath);
for (String key : p.stringPropertyNames()) {
String val = p.getProperty(key);
// e.g. numeric checks for maxActive, initialSize, etc.
if (key.endsWith("Active") || key.endsWith("Size")) Integer.parseInt(val);
} Try / catch
try {
ds.setFilters("config"); ds.init();
} catch (IllegalArgumentException e) {
if (e.getMessage().equals("Config DataSource error.") && e.getCause() instanceof SQLException) {
// the cause names the offending property; fix config file and reload
}
throw e;
} Prevention
- Validate all properties in the config file against DruidDataSourceFactory's accepted keys and types.
- Version-control the config file and lint it in CI.
- Apply the same value constraints documented for setters (errors 12-16).
When it happens
Trigger: A valid config file was loaded (loadPropertyFromConfigFile returned non-null) but one of the applied properties is malformed - e.g. an unparseable numeric pool-sizing property, an invalid driver class, or a setter validation that throws SQLException.
Common situations: config.file points at a properties file with a typo (e.g. maxActive=abc), a deprecated/renamed property key, or a value that violates a setter invariant (see errors 12, 13, 14, 16).
Related errors
- ConfigLoader only support DruidDataSource
- Cannot load remote config file from the [config.file={config
- Failed to decrypt.
- {className}
- maxEvictableIdleTimeMillis must be grater than minEvictableI
AI-assisted analysis of alibaba/druid@fa8dc99126 (2026-08-14).
Data as JSON: /api/errors/592e32db2d2cd618.
Report an issue: GitHub.