public static void fillSerializedValue(BytesAndBitsForCompactor wrapper, Object obj,
      byte userBits) {
    if (obj == null || obj == Token.NOT_AVAILABLE || Token.isInvalidOrRemoved(obj)) {
      throw new IllegalArgumentException(
          String.format("Must not serialize %s in this context.", obj));
    }
    HeapDataOutputStream hdos = null;
    try {
      if (wrapper.getBytes().length < 32) {
        hdos = new HeapDataOutputStream(KnownVersion.CURRENT);
      } else {
        hdos = new HeapDataOutputStream(wrapper.getBytes());
      }
      DataSerializer.writeObject(obj, hdos);
      // return hdos.toByteArray();
      hdos.sendTo(wrapper, userBits);
    } catch (IOException e) {
      RuntimeException e2 = new IllegalArgumentException(
          "An IOException was thrown while serializing.", e);
      throw e2;
    } finally {
      if (hdos != null) {
        hdos.close();
      }
    }
  }
Serialize an object into a <code>byte[]</code> . If the byte array provided by the wrapper is
sufficient to hold the data, it is used otherwise a new byte array gets created & its reference
is stored in the wrapper. The User Bit is also appropriately set as Serialized

@param wrapper Object of type BytesAndBitsForCompactor which is used to fetch the serialized
       data. The byte array of the wrapper is used if possible else a the new byte array
       containing the data is set in the wrapper.
@throws IllegalArgumentException If <code>obj</code> should not be serialized
geode-core/src/main/java/org/apache/geode/internal/cache/EntryEventImpl.java