public static MessageMetadata deserializeMessageMetadata(DataInputStream stream) throws IOException {
    MessageMetadata messageMetadata;
    short version = stream.readShort();
    switch (version) {
      case MESSAGE_METADATA_VERSION_V1:
        ByteBuffer encryptionKey = Utils.readIntBuffer(stream);
        // An empty encryption key could mean that the original before serialization was null or empty. Either way
        // denotes the absence of a key.
        messageMetadata = new MessageMetadata(version, encryptionKey);
        break;
      default:
        throw new IllegalStateException("Unknown MessageMetadata version");
    }
    return messageMetadata;
  }
Deserialize MessageMetadata from the given {@link DataInputStream}
@param stream the stream to read bytes from.
@return the deserialized MessageMetadata.
@throws IOException if an error occurs reading from the stream.
ambry-messageformat/src/main/java/com/github/ambry/messageformat/MessageMetadata.java