public MetadataBlockType getType() {
    return _errCodeToExceptionMap.isEmpty() ? MetadataBlockType.EOS : MetadataBlockType.ERROR;
  }
@Test
  public void v0EosWithExceptionsIsDecodedAsV2ErrorWithSameExceptions()
      throws IOException {
    // Given:
    // MetadataBlock used to be encoded without any data, we should make sure that
    // during rollout or if server versions are mismatched that we can still handle
    // the old format
    V0MetadataBlock legacyBlock = new V0MetadataBlock();
    legacyBlock.addException(250, "timeout");
    byte[] bytes = legacyBlock.toBytes();

    // When:
    ByteBuffer buff = ByteBuffer.wrap(bytes);
    DataBlockUtils.readVersionType(buff); // consume the version information before decoding
    MetadataBlock metadataBlock = new MetadataBlock(buff);

    // Then:
    assertEquals(metadataBlock.getType(), MetadataBlock.MetadataBlockType.ERROR);
    assertEquals(metadataBlock.getExceptions(), legacyBlock.getExceptions(), "Expected exceptions");
  }