Skip to content

Commit 17dee65

Browse files
authored
bugfix:fix the compatibility issue of yml configuration files (apache#7624)
1 parent 08a8a70 commit 17dee65

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

changes/en-us/2.x.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Add changes here for all PR submitted to the 2.x branch.
3535
- [[#7568](https://github.com/apache/incubator-seata/pull/7568)] Fix order() behavior in GlobalTransactionalInterceptorHandler to ensure correct sorting of invocation handlers
3636
- [[#7596](https://github.com/apache/incubator-seata/pull/7596)] Fixed the issue where deserialization failed when the xss filter obtained the default keyword
3737
- [[#7613](https://github.com/apache/incubator-seata/pull/7613)] Fixed the SQL error in the datetime format time query in the global lock query
38+
- [[#7624](https://github.com/apache/incubator-seata/pull/7624)] fix the compatibility issue of yml configuration files
3839

3940

4041

changes/zh-cn/2.x.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
- [[#7568](https://github.com/apache/incubator-seata/pull/7568)] 修复 GlobalTransactionalInterceptorHandler 中的 order() 方法行为,确保拦截器的正确排序
3737
- [[#7596](https://github.com/apache/incubator-seata/pull/7596)] 修复xss过滤器获取默认关键字时反序列化失败的问题
3838
- [[#7613](https://github.com/apache/incubator-seata/pull/7613)] 修复全局锁查询中的datetime时间格式时间查询sql错误
39+
- [[#7624](https://github.com/apache/incubator-seata/pull/7624)] 修复yml配置文件中对于整数的兼容问题
3940

4041

4142
### optimize:

config/seata-config-core/src/main/java/org/apache/seata/config/processor/ProcessorYaml.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.yaml.snakeyaml.Yaml;
2323
import org.yaml.snakeyaml.constructor.SafeConstructor;
2424

25+
import java.util.LinkedHashMap;
2526
import java.util.Map;
2627
import java.util.Properties;
2728

@@ -36,7 +37,11 @@ public class ProcessorYaml implements Processor {
3637
public Properties processor(String config) {
3738
Properties properties = new Properties();
3839
Map<String, Object> configMap = MapUtil.asMap(new Yaml(new SafeConstructor(new LoaderOptions())).load(config));
39-
properties.putAll(MapUtil.getFlattenedMap(configMap));
40+
Map<String, String> stringConfigMap = new LinkedHashMap<>();
41+
MapUtil.getFlattenedMap(configMap).forEach((k, v) -> {
42+
stringConfigMap.put(k, v == null ? null : String.valueOf(v));
43+
});
44+
properties.putAll(stringConfigMap);
4045
return properties;
4146
}
4247
}

config/seata-config-core/src/test/java/org/apache/seata/config/processor/ProcessorYamlTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ void testProcessor_NormalYaml() {
3838
ProcessorYaml processorYaml = new ProcessorYaml();
3939
Properties props = processorYaml.processor(yamlConfig);
4040

41-
assertEquals(8080, props.get("server.port"));
42-
assertEquals("", props.getProperty("server.port", ""));
41+
assertEquals("8080", props.getProperty("server.port", ""));
4342
assertEquals("localhost", props.getProperty("server.host"));
4443
assertEquals("jdbc:mysql://localhost:3306/test", props.getProperty("spring.datasource.url"));
4544
assertEquals("root", props.getProperty("spring.datasource.username"));

0 commit comments

Comments
 (0)