Skip to content
Snippets Groups Projects
Commit 40536e36 authored by Tathagata Das's avatar Tathagata Das
Browse files

Fixed nasty corner case bug in ByteBufferInputStream. Could not add a test...

Fixed nasty corner case bug in ByteBufferInputStream. Could not add a test case for this as I could not figure out how to deterministically reproduce the bug in a short testcase.
parent 2893b305
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,7 @@ class ByteBufferInputStream(buffer: ByteBuffer) extends InputStream {
if (buffer.remaining() == 0) {
-1
} else {
buffer.get()
buffer.get() & 0xFF
}
}
......@@ -17,9 +17,13 @@ class ByteBufferInputStream(buffer: ByteBuffer) extends InputStream {
}
override def read(dest: Array[Byte], offset: Int, length: Int): Int = {
val amountToGet = math.min(buffer.remaining(), length)
buffer.get(dest, offset, amountToGet)
return amountToGet
if (buffer.remaining() == 0) {
-1
} else {
val amountToGet = math.min(buffer.remaining(), length)
buffer.get(dest, offset, amountToGet)
amountToGet
}
}
override def skip(bytes: Long): Long = {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment