davidradl commented on code in PR #26776:
URL: https://github.com/apache/flink/pull/26776#discussion_r2207023994


##########
flink-core/src/test/java/org/apache/flink/api/java/ClosureCleanerTest.java:
##########
@@ -133,6 +135,30 @@ void testComplexTopLevelClassClean() throws Exception {
         assertThat(result).isEqualTo(5);
     }
 
+    @Test
+    public void testCleanNonSerializableNestedMap() throws Exception {
+        MapFunction<Integer, Integer> complexMap =
+                new ComplexMap(
+                        new MapFunction<>() {
+                            private final Object obj = new Object(); // 
non-serializable
+
+                            @Override
+                            public Integer map(Integer value) {
+                                return value + obj.hashCode();
+                            }
+                        });
+        try {
+            ClosureCleaner.clean(complexMap, 
ExecutionConfig.ClosureCleanerLevel.RECURSIVE, true);
+            fail("Should have failed with InvalidProgramException exception");
+        } catch (InvalidProgramException e) {
+            final String msg = e.getMessage();
+            // Verify that the error message contains the reference chain
+            final String regex =
+                    ".*ComplexMap -> .*LocalMap -> .*ClosureCleanerTest.* -> 
.*Object.*";

Review Comment:
   nits: this looks useful. I have some comments in case they are useful for 
you. You do not need to act on them.
   - I wonder about the use of `->` as the classes could have children so a 
list does not necessarily represent the branching. Would it be worth using `,` 
as the separator? 
   - I assume it is not just the class but also the value that could cause this 
to be not able to be serialized.. It might be that we have values with the same 
type at different locations in the children. I do not know how hard these 
issues are to debug; we could use the declared fields to serialize the object 
child by child to find out which one is  
   not serializing?
   



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