Skip to content

Commit dceafdf

Browse files
authored
Issue warnings when dataSourceConfiguration and dataSourceProviderFn are set (#34395)
* Issue warnings when withDataSourceConfiguration and withDataSourceProviderFn are set * spotless
1 parent e6c45eb commit dceafdf

File tree

1 file changed

+12
-0
lines changed
  • sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc

1 file changed

+12
-0
lines changed

sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcIO.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,12 @@ public ReadRows withDataSourceConfiguration(DataSourceConfiguration config) {
778778

779779
public ReadRows withDataSourceProviderFn(
780780
SerializableFunction<Void, DataSource> dataSourceProviderFn) {
781+
if (getDataSourceProviderFn() != null
782+
&& !(getDataSourceProviderFn()
783+
instanceof DataSourceProviderFromDataSourceConfiguration)) {
784+
LOG.warn(
785+
"Both withDataSourceConfiguration and withDataSourceProviderFn are provided. dataSourceProviderFn will override dataSourceConfiguration.");
786+
}
781787
return toBuilder().setDataSourceProviderFn(dataSourceProviderFn).build();
782788
}
783789

@@ -948,6 +954,12 @@ public Read<T> withDataSourceConfiguration(final DataSourceConfiguration config)
948954

949955
public Read<T> withDataSourceProviderFn(
950956
SerializableFunction<Void, DataSource> dataSourceProviderFn) {
957+
if (getDataSourceProviderFn() != null
958+
&& !(getDataSourceProviderFn()
959+
instanceof DataSourceProviderFromDataSourceConfiguration)) {
960+
LOG.warn(
961+
"Both withDataSourceConfiguration and withDataSourceProviderFn are provided. dataSourceProviderFn will override dataSourceConfiguration.");
962+
}
951963
return toBuilder().setDataSourceProviderFn(dataSourceProviderFn).build();
952964
}
953965

0 commit comments

Comments
 (0)