You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/07/06 10:12:03 UTC

[GitHub] [flink] pnowojski commented on a diff in pull request #20158: [FLINK-28357][datastream] Disallow null elements in StreamNode#typeSerializersIn

pnowojski commented on code in PR #20158:
URL: https://github.com/apache/flink/pull/20158#discussion_r914665324


##########
flink-streaming-java/src/main/java/org/apache/flink/streaming/api/graph/StreamNode.java:
##########
@@ -265,17 +266,19 @@ public void setOperatorDescription(String operatorDescription) {
 
     public void setSerializersIn(TypeSerializer<?>... typeSerializersIn) {
         checkArgument(typeSerializersIn.length > 0);
-        this.typeSerializersIn = typeSerializersIn;
+        // Unfortunately code above assumes type serializer can be null, while users of for example
+        // getTypeSerializersIn would be confused by returning an array size of two with all
+        // elements set to null...
+        this.typeSerializersIn =
+                Arrays.stream(typeSerializersIn)
+                        .filter(typeSerializer -> typeSerializer != null)
+                        .toArray(TypeSerializer<?>[]::new);
     }
 
     public TypeSerializer<?>[] getTypeSerializersIn() {

Review Comment:
   It must be kept in sync with `StreamNode#getInEdges`. Each edge has it's own input serializer. It can never happen that first element is null, second is not null. Sources have zero inputs, one input task has single input, two input tasks have two inputs, multi input tasks have N inputs. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org