Skip to content

Commit

Permalink
SPARK-4805 [CORE] BlockTransferMessage.toByteArray() trips assertion
Browse files Browse the repository at this point in the history
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

(cherry picked from commit d8f84f2)
Signed-off-by: Aaron Davidson <aaron@databricks.com>
  • Loading branch information
srowen authored and aarondav committed Dec 10, 2014
1 parent 51da2c5 commit b0d64e5
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ public static BlockTransferMessage fromByteArray(byte[] msg) {

/** 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();
Expand Down

0 comments on commit b0d64e5

Please sign in to comment.