You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "je-ik (via GitHub)" <gi...@apache.org> on 2023/06/20 13:44:35 UTC

[GitHub] [flink] je-ik commented on a diff in pull request #22551: [FLINK-31919][core] Only run closure cleaner if serialization fails

je-ik commented on code in PR #22551:
URL: https://github.com/apache/flink/pull/22551#discussion_r1235292316


##########
flink-core/src/main/java/org/apache/flink/api/java/ClosureCleaner.java:
##########
@@ -169,7 +175,17 @@ && needsRecursion(f, fieldObject)) {
     private static boolean needsRecursion(Field f, Object fo) {
         return (fo != null
                 && !Modifier.isStatic(f.getModifiers())
-                && !Modifier.isTransient(f.getModifiers()));
+                && !Modifier.isTransient(f.getModifiers())
+                && !canBeSerialized(fo));
+    }
+
+    private static boolean canBeSerialized(Object o) {
+        try {
+            InstantiationUtil.serializeObject(o);
+            return true;
+        } catch (Exception e) {

Review Comment:
   FWIW, it might be good idea to log the exception here (debug level) or catch directly NotSerializableException, otherwise this might hide some other exceptions.



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