@Retained(OffHeapIdentifier.GATEWAY_SENDER_EVENT_IMPL_VALUE)
  protected void initializeValue(EntryEventImpl event) {
    // Set the value to be a byte[] representation of either the value or
    // substituteValue (if set).
    if (substituteValue == null) {
      // If the value is already serialized, use it.
      valueIsObject = 0x01;
      /*
       * so ends up being stored in this.valueObj
       */
      @Retained(OffHeapIdentifier.GATEWAY_SENDER_EVENT_IMPL_VALUE)
      StoredObject so;
      {
        ReferenceCountHelper.setReferenceCountOwner(this);
        so = event.getOffHeapNewValue();
        ReferenceCountHelper.setReferenceCountOwner(null);
      }

      if (so != null) {
        // Since GatewaySenderEventImpl instances can live for a long time in the gateway region
        // queue we do not want the StoredObject to be one that keeps the heap form cached.
        so = so.getStoredObjectWithoutHeapForm();
        valueObj = so;
        if (!so.isSerialized()) {
          valueIsObject = 0x00;
        }
      } else if (event.getCachedSerializedNewValue() != null) {
        // We want this to have lower precedence than StoredObject so that the gateway
        // can share a reference to the off-heap value.
        value = event.getCachedSerializedNewValue();
      } else {
        final Object newValue = event.getRawNewValue();
        assert !(newValue instanceof StoredObject); // since we already called getOffHeapNewValue()
                                                    // and it returned null
        if (newValue instanceof CachedDeserializable) {
          value = ((CachedDeserializable) newValue).getSerializedValue();
        } else if (newValue instanceof byte[]) {
          // The value is byte[]. Set _valueIsObject flag to 0x00 (not an object)
          value = (byte[]) newValue;
          valueIsObject = 0x00;
        } else {
          // The value is an object. It will be serialized later when getSerializedValue is called.
          valueObj = newValue;
          // to prevent bug 48281 we need to serialize it now
          getSerializedValue();
          valueObj = null;
        }
      }
    } else {
      // The substituteValue is set. Use it.
      if (substituteValue instanceof byte[]) {
        // The substituteValue is byte[]. Set valueIsObject flag to 0x00 (not an object)
        value = (byte[]) substituteValue;
        valueIsObject = 0x00;
      } else if (substituteValue == TOKEN_NULL) {
        // The substituteValue represents null. Set the value and substituteValue to null.
        value = null;
        substituteValue = null;
        valueIsObject = 0x01;
      } else {
        // The substituteValue is an object. Leave it as is.
        valueIsObject = 0x01;
      }
    }
  }
Initialize this instance. Get the useful parts of the input operation and event.
geode-core/src/main/java/org/apache/geode/internal/cache/wan/GatewaySenderEventImpl.java