phanikumv commented on code in PR #69125:
URL: https://github.com/apache/airflow/pull/69125#discussion_r3496555064


##########
java-sdk/sdk/src/main/kotlin/org/apache/airflow/sdk/execution/Comm.kt:
##########
@@ -72,17 +104,18 @@ class CoordinatorComm(
       return
     }
 
-    val payloadLength = Frame.parseLengthPrefix(prefix)
-    val payload = reader.readByteArray(payloadLength)
-    if (payload.size != payloadLength) { // Something is terribly wrong. Let's 
bail.
-      logger.error(
-        "Payload length not right",
-        mapOf("expect" to payloadLength, "receive" to payload.size),
-      )
-      shutDownRequested = true
-      return
-    }
-    val frame = decode(payload)
+    val declaredLength = Frame.parseLengthPrefix(prefix)
+    val frame =
+      try {
+        Frame.decode(ChannelFrameInput(reader, declaredLength))
+      } catch (e: Exception) {
+        logger.error(
+          "Failed to read or decode frame",
+          mapOf("length" to declaredLength, "exception" to e),
+        )
+        shutDownRequested = true
+        return
+      }

Review Comment:
   (needs `import kotlinx.coroutines.CancellationException`) 
   
   catch (e: Exception) also catches `CancellationException`, so a cancellation 
during decode becomes a clean shutdown instead of propagating. Minor and
   pre-existing in this file, but the new broad catch makes it worth rethrowing.



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