public static byte[] readBytesFromStream(InputStream stream, byte[] data, int offset, int size) throws IOException {
    int read = 0;
    while (read < size) {
      int sizeRead = stream.read(data, offset, size - read);
      if (sizeRead == 0 || sizeRead == -1) {
        throw new IOException("Total size read " + read + " is less than the size to be read " + size);
      }
      read += sizeRead;
      offset += sizeRead;
    }
    return data;
  }
Read "size" length of bytes from stream to a byte array starting at the given offset in the byte[]. If "size"
length of bytes can't be read because the end of the stream has been reached, IOException is thrown. This method
blocks until input data is available, the end of the stream is detected, or an exception is thrown.
@param stream from which data to be read from
@param data byte[] into which the data has to be written
@param offset starting offset in the byte[] at which the data has to be written to
@param size length of bytes to be read from the stream
@return byte[] which has the data that is read from the stream. Same as @param data
@throws IOException
ambry-utils/src/main/java/com/github/ambry/utils/Utils.java