{"record":{"id":"86b7435c4a9f70c5","repo":"apache/beam","slug":"both-withdatasourceconfiguration-and","errorCode":null,"errorMessage":"Both withDataSourceConfiguration and withDataSourceProviderFn are provided. dataSourceProviderFn will override dataSourceConfiguration.","messagePattern":"Both withDataSourceConfiguration and withDataSourceProviderFn are provided\\. dataSourceProviderFn will override dataSourceConfiguration\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcIO.java","lineNumber":881,"sourceCode":"      abstract Builder setOutputParallelization(boolean outputParallelization);\n\n      abstract Builder setDisableAutoCommit(boolean disableAutoCommit);\n\n      abstract Builder setSchema(@Nullable Schema schema);\n\n      abstract ReadRows build();\n    }\n\n    public ReadRows withDataSourceConfiguration(DataSourceConfiguration config) {\n      return withDataSourceProviderFn(new DataSourceProviderFromDataSourceConfiguration(config));\n    }\n\n    public ReadRows withDataSourceProviderFn(\n        SerializableFunction<Void, DataSource> dataSourceProviderFn) {\n      if (getDataSourceProviderFn() != null\n          && !(getDataSourceProviderFn()\n              instanceof DataSourceProviderFromDataSourceConfiguration)) {\n        LOG.warn(\n            \"Both withDataSourceConfiguration and withDataSourceProviderFn are provided. dataSourceProviderFn will override dataSourceConfiguration.\");\n      }\n      return toBuilder().setDataSourceProviderFn(dataSourceProviderFn).build();\n    }\n\n    public ReadRows withQuery(String query) {\n      checkArgument(query != null, \"query can not be null\");\n      return withQuery(ValueProvider.StaticValueProvider.of(query));\n    }\n\n    public ReadRows withQuery(ValueProvider<String> query) {\n      checkArgument(query != null, \"query can not be null\");\n      return toBuilder().setQuery(query).build();\n    }\n\n    public ReadRows withStatementPreparator(StatementPreparator statementPreparator) {\n      checkArgument(statementPreparator != null, \"statementPreparator can not be null\");\n      return toBuilder().setStatementPreparator(statementPreparator).build();","sourceCodeStart":863,"sourceCodeEnd":899,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcIO.java#L863-L899","documentation":"A JdbcIO.ReadRows builder warning: the user has called both withDataSourceConfiguration and a custom withDataSourceProviderFn. The custom provider function will take precedence and the data source configuration will be ignored. The builder does not fail — it logs this warning and proceeds.","triggerScenarios":"Calling withDataSourceProviderFn(fn) on a ReadRows whose dataSourceProviderFn is already set to something other than the default DataSourceProviderFromDataSourceConfiguration wrapper — i.e., a genuinely custom fn plus an explicit DataSourceConfiguration.","commonSituations":"Copy-pasted fluent builder chains where withDataSourceConfiguration(...) was left in place before adding a custom DataSource provider (e.g., HikariCP-backed fn), migrating configuration-based setup to a pooled DataSource without removing the old call.","solutions":["Remove the withDataSourceConfiguration(...) call if you intend to use your custom provider function","Or remove withDataSourceProviderFn and rely solely on withDataSourceConfiguration","Verify at runtime which DataSource is actually used (the custom fn wins) by inspecting connection properties"],"exampleFix":"// before\nJdbcIO.<T>readRows()\n  .withDataSourceConfiguration(JdbcIO.DataSourceConfiguration.create(driver, url))\n  .withDataSourceProviderFn(myHikariFn)\n// after\nJdbcIO.<T>readRows()\n  .withDataSourceProviderFn(myHikariFn)","handlingStrategy":"validation","validationCode":"// guard in your pipeline-construction helper\nif (config != null && providerFn != null) {\n  LOG.warn(\"Pick one data source mechanism; providerFn will override config\");\n  config = null;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never mix withDataSourceConfiguration and withDataSourceProviderFn in one builder chain","Centralize JDBC data-source creation in one factory so only one path is ever set","Grep builder chains during refactors for leftover configuration calls","Prefer DataSourceProviderFromDataSourceConfiguration if you need config-style setup with pooling"],"tags":["jdbc","beam","config","builder"],"backgroundTag":"conflicting-config-options","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}