You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by lz...@apache.org on 2022/04/04 07:24:16 UTC
[flink-table-store] 04/04: [hotfix] Remove java reflect in TableConfigUtils
This is an automated email from the ASF dual-hosted git repository.
lzljs3620320 pushed a commit to branch release-0.1
in repository https://gitbox.apache.org/repos/asf/flink-table-store.git
commit cf58bfff99b9b58e128b03a234fe8afbb093b631
Author: JingsongLi <lz...@aliyun.com>
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;
}
}