Ryan created FLINK-18961:
----------------------------
Summary: In the case of FlatMap linking map, if map returns null, an exception will be thrown in FlatMap
Key: FLINK-18961
URL:
https://issues.apache.org/jira/browse/FLINK-18961 Project: Flink
Issue Type: Bug
Components: API / DataSet
Affects Versions: 1.11.0
Environment: Mac OS 10.13.6
Kubernetes 1.16.8
Flink 1.11.0
Reporter: Ryan
Attachments: Lark20200814-173817.png, Lark20200814-173821.png, Lark20200814-173824.png
I found a DateSet problem. In the case of FlatMap linking map, if map returns null, an exception will be thrown in FlatMap.I think it's a problem with the operator chain.I will post a screenshot of the corresponding stack call in the attachment.
{code:java}
text.filter(value -> value.f0.contains("any")).flatMap(new FlatMapFunction<Tuple2<String, String>, String>() {
@Override
public void flatMap(Tuple2<String, String> value, Collector<String> out) throws Exception {
Pattern pattern = Pattern.compile("\".*\"");
Matcher matcher = pattern.matcher(value.f0);
if(matcher.find()){
String match = matcher.group(0);
out.collect(match); // here throw Exception
}
}
}).map(value -> {
try {
String jsonS = value.replace("\"\"","\"");
jsonS = jsonS.substring(1,jsonS.length()-1);
JSONObject json = JSONObject.parseObject(jsonS);
String result = json.getJSONObject("body").getJSONObject("message").getString("data");
return result; // this is null
}catch (Exception e){
return value;
}
}).print();{code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)