Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
doujutun3207
flink
提交
1c3c663b
F
flink
项目概览
doujutun3207
/
flink
与 Fork 源项目一致
从无法访问的项目Fork
通知
24
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
flink
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1c3c663b
编写于
12月 25, 2018
作者:
X
Xingcan Cui
提交者:
Timo Walther
1月 04, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[FLINK-11227] [table] Fix bound checking errors in DescriptorProperties
This closes #7373.
上级
d3f0075b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
44 addition
and
5 deletion
+44
-5
flink-libraries/flink-table-common/src/main/java/org/apache/flink/table/descriptors/DescriptorProperties.java
.../apache/flink/table/descriptors/DescriptorProperties.java
+2
-2
flink-libraries/flink-table/src/test/scala/org/apache/flink/table/descriptors/DescriptorPropertiesTest.scala
...he/flink/table/descriptors/DescriptorPropertiesTest.scala
+42
-3
未找到文件。
flink-libraries/flink-table-common/src/main/java/org/apache/flink/table/descriptors/DescriptorProperties.java
浏览文件 @
1c3c663b
...
...
@@ -938,7 +938,7 @@ public class DescriptorProperties {
}
// validate
for
(
int
i
=
0
;
i
<
maxIndex
;
i
++)
{
for
(
int
i
=
0
;
i
<
=
maxIndex
;
i
++)
{
for
(
Map
.
Entry
<
String
,
Consumer
<
String
>>
subKey
:
subKeyValidation
.
entrySet
())
{
final
String
fullKey
=
key
+
'.'
+
i
+
'.'
+
subKey
.
getKey
();
if
(
properties
.
containsKey
(
fullKey
))
{
...
...
@@ -1134,7 +1134,7 @@ public class DescriptorProperties {
}
// validate array elements
for
(
int
i
=
0
;
i
<
maxIndex
;
i
++)
{
for
(
int
i
=
0
;
i
<
=
maxIndex
;
i
++)
{
final
String
fullKey
=
key
+
'.'
+
i
;
if
(
properties
.
containsKey
(
fullKey
))
{
// run validation logic
...
...
flink-libraries/flink-table/src/test/scala/org/apache/flink/table/descriptors/DescriptorPropertiesTest.scala
浏览文件 @
1c3c663b
...
...
@@ -20,6 +20,7 @@ package org.apache.flink.table.descriptors
import
java.util
import
java.util.Collections
import
java.util.function.Consumer
import
org.apache.flink.table.api.ValidationException
import
org.apache.flink.table.util.JavaScalaConversionUtil.toJava
...
...
@@ -32,6 +33,9 @@ import org.junit.Test
class
DescriptorPropertiesTest
{
private
val
ARRAY_KEY
=
"my-array"
private
val
FIXED_INDEXED_PROPERTY_KEY
=
"my-fixed-indexed-property"
private
val
PROPERTY_1_KEY
=
"property-1"
private
val
PROPERTY_2_KEY
=
"property-2"
@Test
def
testEquals
()
:
Unit
=
{
...
...
@@ -97,8 +101,8 @@ class DescriptorPropertiesTest {
def
testArrayInvalidValues
()
:
Unit
=
{
val
properties
=
new
DescriptorProperties
()
properties
.
putString
(
s
"$ARRAY_KEY.0"
,
"12"
)
properties
.
putString
(
s
"$ARRAY_KEY.1"
,
"
INVALID
"
)
properties
.
putString
(
s
"$ARRAY_KEY.2"
,
"
66
"
)
properties
.
putString
(
s
"$ARRAY_KEY.1"
,
"
66
"
)
properties
.
putString
(
s
"$ARRAY_KEY.2"
,
"
INVALID
"
)
testArrayValidation
(
properties
,
1
,
Integer
.
MAX_VALUE
)
}
...
...
@@ -118,6 +122,19 @@ class DescriptorPropertiesTest {
testArrayValidation
(
properties
,
1
,
Integer
.
MAX_VALUE
)
}
@Test
(
expected
=
classOf
[
ValidationException
])
def
testInvalidFixedIndexedProperties
()
:
Unit
=
{
val
property
=
new
DescriptorProperties
()
val
list
=
new
util
.
ArrayList
[
util.List
[
String
]]()
list
.
add
(
util
.
Arrays
.
asList
(
"1"
,
"string"
))
list
.
add
(
util
.
Arrays
.
asList
(
"INVALID"
,
"string"
))
property
.
putIndexedFixedProperties
(
FIXED_INDEXED_PROPERTY_KEY
,
util
.
Arrays
.
asList
(
PROPERTY_1_KEY
,
PROPERTY_2_KEY
),
list
)
testFixedIndexedPropertiesValidation
(
property
)
}
@Test
def
testRemoveKeys
()
:
Unit
=
{
val
properties
=
new
DescriptorProperties
()
...
...
@@ -155,7 +172,7 @@ class DescriptorPropertiesTest {
minLength
:
Int
,
maxLength
:
Int
)
:
Unit
=
{
val
validator
:
(
String
)
=>
Unit
=
(
key
:
String
)
=>
{
val
validator
:
String
=>
Unit
=
(
key
:
String
)
=>
{
properties
.
validateInt
(
key
,
false
)
}
...
...
@@ -165,4 +182,26 @@ class DescriptorPropertiesTest {
minLength
,
maxLength
)
}
private
def
testFixedIndexedPropertiesValidation
(
properties
:
DescriptorProperties
)
:
Unit
=
{
val
validatorMap
=
new
util
.
HashMap
[
String
,
Consumer
[
String
]]()
// PROPERTY_1 should be Int
val
validator1
:
String
=>
Unit
=
(
key
:
String
)
=>
{
properties
.
validateInt
(
key
,
false
)
}
validatorMap
.
put
(
PROPERTY_1_KEY
,
toJava
(
validator1
))
// PROPERTY_2 should be String
val
validator2
:
String
=>
Unit
=
(
key
:
String
)
=>
{
properties
.
validateString
(
key
,
false
)
}
validatorMap
.
put
(
PROPERTY_2_KEY
,
toJava
(
validator2
))
properties
.
validateFixedIndexedProperties
(
FIXED_INDEXED_PROPERTY_KEY
,
false
,
validatorMap
)
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录