Skip to content
Snippets Groups Projects
Commit d8f84f26 authored by Sean Owen's avatar Sean Owen Committed by Aaron Davidson
Browse files

SPARK-4805 [CORE] BlockTransferMessage.toByteArray() trips assertion

Allocate enough room for type byte as well as message, to avoid tripping assertion about capacity of the buffer

Author: Sean Owen <sowen@cloudera.com>

Closes #3650 from srowen/SPARK-4805 and squashes the following commits:

9e1d502 [Sean Owen] Allocate enough room for type byte as well as message, to avoid tripping assertion about capacity of the buffer
parent 5e4c06f8
No related branches found
No related tags found
No related merge requests found
......@@ -67,7 +67,8 @@ public abstract class BlockTransferMessage implements Encodable {
/** Serializes the 'type' byte followed by the message itself. */
public byte[] toByteArray() {
ByteBuf buf = Unpooled.buffer(encodedLength());
// Allow room for encoded message, plus the type byte
ByteBuf buf = Unpooled.buffer(encodedLength() + 1);
buf.writeByte(type().id);
encode(buf);
assert buf.writableBytes() == 0 : "Writable bytes remain: " + buf.writableBytes();
......
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