Myasuka commented on code in PR #27186:
URL: https://github.com/apache/flink/pull/27186#discussion_r2547013397


##########
flink-runtime/src/test/java/org/apache/flink/runtime/util/SerializedThrowableTest.java:
##########
@@ -179,4 +187,60 @@ void testCopySuppressed() {
                 .isInstanceOf(SerializedThrowable.class)
                 .hasMessage("java.lang.Exception: suppressed");
     }
+
+    @Test
+    void testCyclicSuppressedThrowableSerialized() {
+        SerializedThrowable serializedThrowable = new 
SerializedThrowable(mockThrowable());
+        assertThat(serializedThrowable).isNotNull();
+    }
+
+    @Test
+    void testCyclicSuppressedThrowableConcurrentSerialized() throws 
InterruptedException {

Review Comment:
   I think current PR could help to resolve the StackOverflowError via 
introducing the `alreadySeen` set to deduplicate. 
   
   And the dead lock problem could happen when calling 
`InstantiationUtil.serializeObject(exception);`
   The simplest way to resolve this is synchronizing the function like:
   ```java
       private SerializedThrowable(Throwable exception, Set<Throwable> 
alreadySeen) {
           super(getClassNameAndMessageOrError(exception));
   
           if (!(exception instanceof SerializedThrowable)) {
               // serialize and memoize the original message
               byte[] serialized;
               // introduce the synchronization here to avoid deadlock of multi 
thread serializing exceptions
               synchronized (SerializedThrowable.class) {
                   try {
                       serialized = 
InstantiationUtil.serializeObject(exception);
                   } catch (Throwable t) {
                       serialized = null;
                   }
               }
            // xxx
   ```
   
   I think this could help to resolve the problem.
   



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