{"record":{"id":"e81723ae794d7760","repo":"apache/druid","slug":"connectionproperties-is-null","errorCode":null,"errorMessage":"connectionProperties is null","messagePattern":"connectionProperties is null","errorType":"exception","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"server/src/main/java/org/apache/druid/metadata/BasicDataSourceExt.java","lineNumber":81,"sourceCode":"  @Override\n  public void addConnectionProperty(String name, String value)\n  {\n    connectionProperties.put(name, value);\n    super.addConnectionProperty(name, value);\n  }\n\n  @Override\n  public void removeConnectionProperty(String name)\n  {\n    connectionProperties.remove(name);\n    super.removeConnectionProperty(name);\n  }\n\n  @Override\n  public void setConnectionProperties(String connectionProperties)\n  {\n    if (connectionProperties == null) {\n      throw new NullPointerException(\"connectionProperties is null\");\n    }\n\n    String[] entries = connectionProperties.split(\";\");\n    Properties properties = new Properties();\n    for (String entry : entries) {\n      if (entry.length() > 0) {\n        int index = entry.indexOf('=');\n        if (index > 0) {\n          String name = entry.substring(0, index);\n          String value = entry.substring(index + 1);\n          properties.setProperty(name, value);\n        } else {\n          // no value is empty string which is how java.util.Properties works\n          properties.setProperty(entry, \"\");\n        }\n      }\n    }\n    this.connectionProperties = properties;","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/server/src/main/java/org/apache/druid/metadata/BasicDataSourceExt.java#L63-L99","documentation":"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.","triggerScenarios":"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).","commonSituations":"Druid metadata storage configuration missing the druid.metadata.storage.connector.connectionProperties property; frameworks that invoke all bean setters including null-valued ones.","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"],"exampleFix":"// before\ndataSource.setConnectionProperties(config.getConnectionProperties()); // null\n// after\nString props = config.getConnectionProperties();\nif (props != null) {\n  dataSource.setConnectionProperties(props);\n}","handlingStrategy":"validation","validationCode":"if (connectionProperties == null) { connectionProperties = \"\"; } // or skip the setter call","typeGuard":"if (connectionProperties instanceof String s && !s.isEmpty()) { dataSource.setConnectionProperties(s); }","tryCatchPattern":"try { dataSource.setConnectionProperties(props); } catch (NullPointerException e) { log.warn(\"connectionProperties was null; skipping\"); }","preventionTips":["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"],"tags":["java","jdbc","null-check","datasource-config"],"backgroundTag":"null-argument","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}