Github user JoshRosen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21175#discussion_r188154716
  
    --- Diff: 
core/src/main/scala/org/apache/spark/util/io/ChunkedByteBuffer.scala ---
    @@ -63,10 +63,15 @@ private[spark] class ChunkedByteBuffer(var chunks: 
Array[ByteBuffer]) {
        */
       def writeFully(channel: WritableByteChannel): Unit = {
         for (bytes <- getChunks()) {
    -      while (bytes.remaining() > 0) {
    -        val ioSize = Math.min(bytes.remaining(), bufferWriteChunkSize)
    -        bytes.limit(bytes.position() + ioSize)
    -        channel.write(bytes)
    +      val curChunkLimit = bytes.limit()
    +      while (bytes.hasRemaining) {
    +        try {
    +          val ioSize = Math.min(bytes.remaining(), bufferWriteChunkSize)
    +          bytes.limit(bytes.position() + ioSize)
    +          channel.write(bytes)
    +        } finally {
    --- End diff --
    
    I don't think we need the `try` and `finally` here because `getChunks()` 
returns duplicated ByteBuffers which have their own position and limit.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to