aboutsummaryrefslogtreecommitdiff
path: root/network
diff options
context:
space:
mode:
authorSean Owen <sowen@cloudera.com>2014-12-09 16:38:27 -0800
committerAaron Davidson <aaron@databricks.com>2014-12-09 16:38:27 -0800
commitd8f84f26e388055ca7459810e001d05ab60af15b (patch)
tree667ab58d0c3453151f0f11939d212afc2fa5d647 /network
parent5e4c06f8e54265a4024857f5978ec54c936aeea2 (diff)
downloadspark-d8f84f26e388055ca7459810e001d05ab60af15b.tar.gz
spark-d8f84f26e388055ca7459810e001d05ab60af15b.tar.bz2
spark-d8f84f26e388055ca7459810e001d05ab60af15b.zip
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
Diffstat (limited to 'network')
-rw-r--r--network/shuffle/src/main/java/org/apache/spark/network/shuffle/protocol/BlockTransferMessage.java3
1 files changed, 2 insertions, 1 deletions
diff --git a/network/shuffle/src/main/java/org/apache/spark/network/shuffle/protocol/BlockTransferMessage.java b/network/shuffle/src/main/java/org/apache/spark/network/shuffle/protocol/BlockTransferMessage.java
index b4b13b8a6e..6c1210b332 100644
--- a/network/shuffle/src/main/java/org/apache/spark/network/shuffle/protocol/BlockTransferMessage.java
+++ b/network/shuffle/src/main/java/org/apache/spark/network/shuffle/protocol/BlockTransferMessage.java
@@ -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();