XComp commented on code in PR #23490:
URL: https://github.com/apache/flink/pull/23490#discussion_r1388279563


##########
flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/PojoSerializer.java:
##########
@@ -473,25 +521,41 @@ public T deserialize(T reuse, DataInputView source) 
throws IOException {
             }
         }
 
-        if ((flags & NO_SUBCLASS) != 0) {
+        if (isRecord()) {
             try {
+                JavaRecordBuilderFactory<T>.JavaRecordBuilder builder = 
recordFactory.newBuilder();
                 for (int i = 0; i < numFields; i++) {
                     boolean isNull = source.readBoolean();
 
                     if (fields[i] != null) {
                         if (isNull) {
-                            fields[i].set(reuse, null);
+                            builder.setField(i, null);
                         } else {
-                            Object field;
+                            Object reuseField = reuse == null ? null : 
fields[i].get(reuse);
+                            builder.setField(i, deserializeField(reuseField, 
i, source));
+                        }
+                    } else if (!isNull) {
+                        // read and dump a pre-existing field value
+                        fieldSerializers[i].deserialize(source);
+                    }
+                }
 
-                            Object reuseField = fields[i].get(reuse);
-                            if (reuseField != null) {
-                                field = 
fieldSerializers[i].deserialize(reuseField, source);
-                            } else {
-                                field = 
fieldSerializers[i].deserialize(source);
-                            }
+                reuse = builder.build();
+            } catch (IllegalAccessException e) {
+                throw new RuntimeException(
+                        "Error during POJO copy, this should not happen since 
we check the fields before.",
+                        e);
+            }
+        } else if ((flags & NO_SUBCLASS) != 0) {

Review Comment:
   test



-- 
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