zsxwing commented on a change in pull request #23590: [SPARK-26665][Core]Fix a 
bug that BlockTransferService.fetchBlockSync may hang forever
URL: https://github.com/apache/spark/pull/23590#discussion_r249636799
 
 

 ##########
 File path: 
core/src/main/scala/org/apache/spark/network/BlockTransferService.scala
 ##########
 @@ -107,10 +107,14 @@ abstract class BlockTransferService extends 
ShuffleClient with Closeable with Lo
             case e: EncryptedManagedBuffer =>
               result.success(e)
             case _ =>
-              val ret = ByteBuffer.allocate(data.size.toInt)
-              ret.put(data.nioByteBuffer())
-              ret.flip()
-              result.success(new NioManagedBuffer(ret))
+              try {
+                val ret = ByteBuffer.allocate(data.size.toInt)
+                ret.put(data.nioByteBuffer())
+                ret.flip()
+                result.success(new NioManagedBuffer(ret))
+              } catch {
+                case e: Throwable => result.failure(e)
 
 Review comment:
   `Promise` is the most convenient way to turn an async listener to a Scala 
Future in order to call blocking APIs provided by Future.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to