Github user pathikrit commented on a diff in the pull request: https://github.com/apache/spark/pull/20179#discussion_r160304668 --- Diff: core/src/main/scala/org/apache/spark/rpc/netty/NettyRpcEnv.scala --- @@ -332,15 +332,17 @@ private[netty] class NettyRpcEnv( val pipe = Pipe.open() val source = new FileDownloadChannel(pipe.source()) + var exceptionThrown = true try { val client = downloadClient(parsedUri.getHost(), parsedUri.getPort()) val callback = new FileDownloadCallback(pipe.sink(), source, client) client.stream(parsedUri.getPath(), callback) - } catch { - case e: Exception => + exceptionThrown = false + } finally { + if (exceptionThrown) { pipe.sink().close() --- End diff -- instead of using this var exceptionThrown, can we move these 2 close() calls to the catch block? Current code: ```scala var exceptionThrown = true try { // code exceptionThrown = false } finally { if (exceptionThrown) { pipe.sink().close() source.close() } } ``` Proposed code: ```scala try { // code } catch { case _: Throwable => pipe.sink().close() source.close() } ```
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org