Github user uncleGen commented on a diff in the pull request: https://github.com/apache/spark/pull/15915#discussion_r92104532 --- Diff: core/src/test/scala/org/apache/spark/util/io/ChunkedByteBufferOutputStreamSuite.scala --- @@ -119,4 +119,21 @@ class ChunkedByteBufferOutputStreamSuite extends SparkFunSuite { assert(arrays(1).toSeq === ref.slice(10, 20)) assert(arrays(2).toSeq === ref.slice(20, 30)) } + + test("negative chunk size") { + val ref = new Array[Byte](8 * 1024 * 1024 + 10) + Random.nextBytes(ref) + val o = new ChunkedByteBufferOutputStream(-10, ByteBuffer.allocate) + o.write(ref) + o.close() + val arrays = o.toChunkedByteBuffer.getChunks().map(_.array()) + assert(arrays.length === 3) + assert(arrays(0).length === 4 * 1024 * 1024) + assert(arrays(1).length === 4 * 1024 * 1024) + assert(arrays(2).length === 10 ) + + assert(arrays(0).toSeq === ref.slice(0, 4 * 1024 * 1024)) + assert(arrays(1).toSeq === ref.slice(4 * 1024 * 1024, 8 * 1024 * 1024)) + assert(arrays(2).toSeq === ref.slice(8 * 1024 * 1024, 8 * 1024 * 1024 + 10)) + } } --- End diff -- Discovery starting. Discovery completed in 42 seconds, 124 milliseconds. Run starting. Expected test count is: 9 ChunkedByteBufferOutputStreamSuite: - empty output - write a single byte - write a single near boundary - write a single at boundary - single chunk output - single chunk output at boundary size - multiple chunk output - multiple chunk output at boundary size - negative chunk size Run completed in 42 seconds, 700 milliseconds. Total number of tests run: 9 Suites: completed 2, aborted 0 Tests: succeeded 9, failed 0, canceled 0, ignored 0, pending 0 All tests passed.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org