Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
SkyWalking
提交
149b359c
S
SkyWalking
项目概览
apache
/
SkyWalking
上一次同步 大约 1 年
通知
302
Star
21345
Fork
6091
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyWalking
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
149b359c
编写于
10月 29, 2021
作者:
Z
zhyyu
提交者:
GitHub
10月 29, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix config yaml data type conversion bug (#8035)
Co-authored-by:
N
yuzhongyu
<
yuzhongyu@cestc.cn
>
上级
32f9ab01
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
51 addition
and
1 deletion
+51
-1
CHANGES.md
CHANGES.md
+1
-0
oap-server/server-starter/src/main/java/org/apache/skywalking/oap/server/starter/config/ApplicationConfigLoader.java
...ng/oap/server/starter/config/ApplicationConfigLoader.java
+16
-1
oap-server/server-starter/src/test/java/org/apache/skywalking/oap/server/starter/config/ApplicationConfigLoaderTestCase.java
...erver/starter/config/ApplicationConfigLoaderTestCase.java
+34
-0
未找到文件。
CHANGES.md
浏览文件 @
149b359c
...
...
@@ -42,6 +42,7 @@ Release Notes.
*
Fix TimeBucket missing in ElasticSearch and provide compatible
`storage2Entity`
for previous versions.
*
Fix ElasticSearch implementation of
`queryMetricsValues`
and
`readLabeledMetricsValues`
doesn't fill default values
when no available data in the ElasticSearch server.
*
Fix config yaml data type conversion bug when meets special character like !.
#### UI
...
...
oap-server/server-starter/src/main/java/org/apache/skywalking/oap/server/starter/config/ApplicationConfigLoader.java
浏览文件 @
149b359c
...
...
@@ -20,6 +20,7 @@ package org.apache.skywalking.oap.server.starter.config;
import
java.io.FileNotFoundException
;
import
java.io.Reader
;
import
java.util.ArrayList
;
import
java.util.Iterator
;
import
java.util.Map
;
import
java.util.Properties
;
...
...
@@ -111,7 +112,7 @@ public class ApplicationConfigLoader implements ConfigLoader<ApplicationConfigur
log
.
info
(
"Provider={} config={} has been set as an empty string"
,
providerName
,
propertyName
);
}
else
{
// Use YAML to do data type conversion.
final
Object
replaceValue
=
yaml
.
load
(
valueString
);
final
Object
replaceValue
=
convertValueString
(
valueString
);
if
(
replaceValue
!=
null
)
{
target
.
replace
(
propertyName
,
replaceValue
);
log
.
info
(
...
...
@@ -125,6 +126,20 @@ public class ApplicationConfigLoader implements ConfigLoader<ApplicationConfigur
}
}
private
Object
convertValueString
(
String
valueString
)
{
try
{
Object
replaceValue
=
yaml
.
load
(
valueString
);
if
(
replaceValue
instanceof
String
||
replaceValue
instanceof
Integer
||
replaceValue
instanceof
Long
||
replaceValue
instanceof
Boolean
||
replaceValue
instanceof
ArrayList
)
{
return
replaceValue
;
}
else
{
return
valueString
;
}
}
catch
(
Exception
e
)
{
log
.
warn
(
"yaml convert value type error, use origin values string. valueString={}"
,
valueString
,
e
);
return
valueString
;
}
}
private
void
overrideConfigBySystemEnv
(
ApplicationConfiguration
configuration
)
{
for
(
Map
.
Entry
<
Object
,
Object
>
prop
:
System
.
getProperties
().
entrySet
())
{
overrideModuleSettings
(
configuration
,
prop
.
getKey
().
toString
(),
prop
.
getValue
().
toString
());
...
...
oap-server/server-starter/src/test/java/org/apache/skywalking/oap/server/starter/config/ApplicationConfigLoaderTestCase.java
浏览文件 @
149b359c
...
...
@@ -38,6 +38,7 @@ public class ApplicationConfigLoaderTestCase {
public
void
setUp
()
throws
ConfigFileNotFoundException
{
System
.
setProperty
(
"SW_STORAGE"
,
"mysql"
);
System
.
setProperty
(
"SW_RECEIVER_ZIPKIN"
,
"default"
);
System
.
setProperty
(
"SW_DATA_SOURCE_PASSWORD"
,
"!AI!3B"
);
ApplicationConfigLoader
configLoader
=
new
ApplicationConfigLoader
();
applicationConfiguration
=
configLoader
.
load
();
}
...
...
@@ -60,4 +61,37 @@ public class ApplicationConfigLoaderTestCase {
assertEquals
(
2
,
instanceNameRule
.
size
());
}
@Test
public
void
testLoadStringTypeConfig
()
{
Properties
providerConfig
=
applicationConfiguration
.
getModuleConfiguration
(
"receiver_zipkin"
)
.
getProviderConfiguration
(
"default"
);
String
host
=
(
String
)
providerConfig
.
get
(
"host"
);
assertEquals
(
"0.0.0.0"
,
host
);
}
@Test
public
void
testLoadIntegerTypeConfig
()
{
Properties
providerConfig
=
applicationConfiguration
.
getModuleConfiguration
(
"receiver_zipkin"
)
.
getProviderConfiguration
(
"default"
);
Integer
port
=
(
Integer
)
providerConfig
.
get
(
"port"
);
assertEquals
(
Integer
.
valueOf
(
9411
),
port
);
}
@Test
public
void
testLoadBooleanTypeConfig
()
{
Properties
providerConfig
=
applicationConfiguration
.
getModuleConfiguration
(
"core"
)
.
getProviderConfiguration
(
"default"
);
Boolean
enableDataKeeperExecutor
=
(
Boolean
)
providerConfig
.
get
(
"enableDataKeeperExecutor"
);
assertEquals
(
Boolean
.
TRUE
,
enableDataKeeperExecutor
);
}
@Test
public
void
testLoadSpecialStringTypeConfig
()
{
Properties
providerConfig
=
applicationConfiguration
.
getModuleConfiguration
(
"storage"
)
.
getProviderConfiguration
(
"mysql"
);
Properties
properties
=
(
Properties
)
providerConfig
.
get
(
"properties"
);
String
password
=
(
String
)
properties
.
get
(
"dataSource.password"
);
assertEquals
(
"!AI!3B"
,
password
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录