This is an automated email from the ASF dual-hosted git repository.
lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink-table-store.git
The following commit(s) were added to refs/heads/master by this push:
new 07ffe47 [hotfix] Remove java reflect in TableConfigUtils
07ffe47 is described below
commit 07ffe478a08b88a29c283d5989c2fae08ccac1c4
Author: JingsongLi <[email protected]>
AuthorDate: Mon Apr 4 15:21:52 2022 +0800
[hotfix] Remove java reflect in TableConfigUtils
---
.../store/connector/utils/TableConfigUtils.java | 25 ++++++++++------------
1 file changed, 11 insertions(+), 14 deletions(-)
diff --git
a/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/utils/TableConfigUtils.java
b/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/utils/TableConfigUtils.java
index eff9d43..f412271 100644
---
a/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/utils/TableConfigUtils.java
+++
b/flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/utils/TableConfigUtils.java
@@ -22,18 +22,19 @@ import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.ReadableConfig;
import org.apache.flink.table.api.TableConfig;
-import java.lang.reflect.Field;
-
/** Utils for {@link TableConfig}. */
public class TableConfigUtils {
public static Configuration extractConfiguration(ReadableConfig
readableConfig) {
- return extractConfiguration(readableConfig, new Configuration());
+ Configuration to = new Configuration();
+ copyConfiguration(readableConfig, to);
+ return to;
}
- private static Configuration extractConfiguration(ReadableConfig from,
Configuration to) {
+ private static void copyConfiguration(ReadableConfig from, Configuration
to) {
if (from instanceof Configuration) {
- return (Configuration) from;
+ to.addAll((Configuration) from);
+ return;
}
if (!(from instanceof TableConfig)) {
@@ -41,15 +42,11 @@ public class TableConfigUtils {
}
TableConfig tableConfig = (TableConfig) from;
- try {
- Field rootField =
TableConfig.class.getDeclaredField("rootConfiguration");
- rootField.setAccessible(true);
- ReadableConfig rootConfig = (ReadableConfig)
rootField.get(tableConfig);
- extractConfiguration(rootConfig, to);
- } catch (NoSuchFieldException | IllegalAccessException e) {
- throw new RuntimeException(e);
- }
+
+ // copy root configuration first
+ copyConfiguration(tableConfig.getRootConfiguration(), to);
+
+ // copy table configuration
to.addAll(tableConfig.getConfiguration());
- return to;
}
}