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


##########
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:
   Does the code calling this method make no assumptions about the indices?
   Let's say the original list of serializers contained 2 elements, with the 
first one being nul
   l.
   How does the code accessing this array figure out that what is now at index 
0 is what it requires?



##########
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:
   Does the code calling this method make no assumptions about the indices?
   Let's say the original list of serializers contained 2 elements, with the 
first one being null.
   How does the code accessing this array figure out that what is now at index 
0 is what it requires?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to