mridulm 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_r249276597
##########
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:
An alternative to catching and ignoring Throwable (after result.failures) is
to use a boolean flag to indicate if `result.success` was signalled - and if
not, invoke `result.failure` in finally.
```
var success = false
try {
...
result.success(...)
success = true
} finally {
if (! success) result.failure(e)
}
```
----------------------------------------------------------------
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]