You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Liu, Linhong (JIRA)" <ji...@apache.org> on 2018/11/15 05:14:00 UTC

[jira] [Updated] (SPARK-26068) ChunkedByteBufferInputStream is truncated by empty chunk

     [ https://issues.apache.org/jira/browse/SPARK-26068?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Liu, Linhong updated SPARK-26068:
---------------------------------
    Description: 
If ChunkedByteBuffer contains empty chunk in the middle of it, then the ChunkedByteBufferInputStream will be truncated. All data behind the empty chunk will not be read.

The problematic code:
{code:java}
// ChunkedByteBuffer.scala
// Assume chunks.next returns an empty chunk, then we will reach
// else branch no matter chunks.hasNext = true or not. So some data is lost.
override def read(dest: Array[Byte], offset: Int, length: Int): Int = {
  if (currentChunk != null && !currentChunk.hasRemaining && chunks.hasNext)    {
    currentChunk = chunks.next()
  }
  if (currentChunk != null && currentChunk.hasRemaining) {
    val amountToGet = math.min(currentChunk.remaining(), length)
    currentChunk.get(dest, offset, amountToGet)
    amountToGet
  } else {
    close()
    -1
  }
} {code}

  was:
If ChunkedByteBuffer contains empty chunk in the middle of it, then the ChunkedByteBufferInputStream will be truncated. All data behind the empty chunk will not be read.

The problematic code:
{code:java}
// ChunkedByteBuffer.scala
// Assume chunks.next returns an empty chunk, then we will reach
// else branch no matter chunks.hasNext = true or not. So some data is lost.
override def read(dest: Array[Byte], offset: Int, length: Int): Int = {
  if (currentChunk != null && !currentChunk.hasRemaining && chunks.hasNext)    {
    currentChunk = chunks.next()
  }
  if (currentChunk != null && currentChunk.hasRemaining) {
    val amountToGet = math.min(currentChunk.remaining(), length)
    currentChunk.get(dest, offset, amountToGet)
    amountToGet
  } else {
    close()
    -1
  }
}
{code}
 

 


> ChunkedByteBufferInputStream is truncated by empty chunk
> --------------------------------------------------------
>
>                 Key: SPARK-26068
>                 URL: https://issues.apache.org/jira/browse/SPARK-26068
>             Project: Spark
>          Issue Type: Bug
>          Components: Spark Core
>    Affects Versions: 3.0.0
>            Reporter: Liu, Linhong
>            Priority: Major
>
> If ChunkedByteBuffer contains empty chunk in the middle of it, then the ChunkedByteBufferInputStream will be truncated. All data behind the empty chunk will not be read.
> The problematic code:
> {code:java}
> // ChunkedByteBuffer.scala
> // Assume chunks.next returns an empty chunk, then we will reach
> // else branch no matter chunks.hasNext = true or not. So some data is lost.
> override def read(dest: Array[Byte], offset: Int, length: Int): Int = {
>   if (currentChunk != null && !currentChunk.hasRemaining && chunks.hasNext)    {
>     currentChunk = chunks.next()
>   }
>   if (currentChunk != null && currentChunk.hasRemaining) {
>     val amountToGet = math.min(currentChunk.remaining(), length)
>     currentChunk.get(dest, offset, amountToGet)
>     amountToGet
>   } else {
>     close()
>     -1
>   }
> } {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org