Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-4805

BlockTransferMessage.toByteArray() trips assertion

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.1.0
    • Fix Version/s: None
    • Component/s: Shuffle, Spark Core
    • Labels:
      None

      Description

      The ByteBuf below is allocated to have enough room to encode just the message, but a type byte is written too. The buffer resizes and is left with capacity, which is a minor waste. But when assertions are on, it fails the assertion below. This is triggered by unit tests, but the Java test for this wasn't running. You can verify that a simple "+1" in the allocated size fixes it.

        public byte[] toByteArray() {
          ByteBuf buf = Unpooled.buffer(encodedLength());
          buf.writeByte(type().id);
          encode(buf);
          assert buf.writableBytes() == 0 : "Writable bytes remain: " + buf.writableBytes();
          return buf.array();
        }
      

      Aaron Davidson

        Attachments

          Activity

            People

            • Assignee:
              srowen Sean R. Owen
              Reporter:
              srowen Sean R. Owen
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: