apache/druid · error · NullPointerException
connectionProperties is null
Error message
connectionProperties is null
What it means
BasicDataSourceExt.setConnectionProperties overrides commons-dbcp's setter and explicitly rejects a null connectionProperties string with NullPointerException. The override parses the semicolon-separated key=value string into a Properties object, so null input cannot be processed.
Source
Thrown at server/src/main/java/org/apache/druid/metadata/BasicDataSourceExt.java:81
@Override
public void addConnectionProperty(String name, String value)
{
connectionProperties.put(name, value);
super.addConnectionProperty(name, value);
}
@Override
public void removeConnectionProperty(String name)
{
connectionProperties.remove(name);
super.removeConnectionProperty(name);
}
@Override
public void setConnectionProperties(String connectionProperties)
{
if (connectionProperties == null) {
throw new NullPointerException("connectionProperties is null");
}
String[] entries = connectionProperties.split(";");
Properties properties = new Properties();
for (String entry : entries) {
if (entry.length() > 0) {
int index = entry.indexOf('=');
if (index > 0) {
String name = entry.substring(0, index);
String value = entry.substring(index + 1);
properties.setProperty(name, value);
} else {
// no value is empty string which is how java.util.Properties works
properties.setProperty(entry, "");
}
}
}
this.connectionProperties = properties;View on GitHub (pinned to 9b90983fd2)
Solutions
- Provide a non-null connectionProperties string in the connector config (may be empty string)
- Skip calling setConnectionProperties when the configured value is null
- Use an empty string instead of null when no extra properties are needed
Example fix
// before
dataSource.setConnectionProperties(config.getConnectionProperties()); // null
// after
String props = config.getConnectionProperties();
if (props != null) {
dataSource.setConnectionProperties(props);
} Defensive patterns
Strategy: validation
Validate before calling
if (connectionProperties == null) { connectionProperties = ""; } // or skip the setter call Type guard
if (connectionProperties instanceof String s && !s.isEmpty()) { dataSource.setConnectionProperties(s); } Try / catch
try { dataSource.setConnectionProperties(props); } catch (NullPointerException e) { log.warn("connectionProperties was null; skipping"); } Prevention
- Always define connectionProperties in metadata storage config, even as an empty string
- Null-check config-derived values before invoking bean setters
- Prefer building the Properties object yourself over string parsing
When it happens
Trigger: Configuring a JDBC data source where the connectionProperties property resolves to null — e.g. metadata store config with no connectionProperties key, or programmatic calls like dataSource.setConnectionProperties(null).
Common situations: Druid metadata storage configuration missing the druid.metadata.storage.connector.connectionProperties property; frameworks that invoke all bean setters including null-valued ones.
Related errors
- Cannot load JDBC driver class '<driverClassName>'
- 08001
- Cannot create JDBC driver of class '<driverClassName>' for c
- Failed to find the DB Driver
- supervisorId cannot be null
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/e81723ae794d7760.
Report an issue: GitHub.