LuciferYang commented on code in PR #45238:
URL: https://github.com/apache/spark/pull/45238#discussion_r1503688318


##########
core/src/main/scala/org/apache/spark/serializer/JavaSerializer.scala:
##########
@@ -118,22 +118,24 @@ private[spark] class JavaSerializerInstance(
 
   override def serialize[T: ClassTag](t: T): ByteBuffer = {
     val bos = new ByteBufferOutputStream()
-    val out = serializeStream(bos)
-    out.writeObject(t)
-    out.close()
+    Utils.tryWithResource(serializeStream(bos)) { out =>

Review Comment:
   There should be other similar cases, for example:
   
   
https://github.com/apache/spark/blob/1a408033daf458f1ceebbe14a560355a1a2c0a70/core/src/main/scala/org/apache/spark/scheduler/TaskDescription.scala#L92-L94
   
   
https://github.com/apache/spark/blob/1a408033daf458f1ceebbe14a560355a1a2c0a70/sql/core/src/main/scala/org/apache/spark/sql/execution/arrow/ArrowConverters.scala#L473
   
   cc @mridulm 



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to