docs: private final int encodePartToBuffer(JsMsgPart jsPart, boolean header, byte[] buffer, int offset) throws MessageEncodeFailedException {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "encodePartToBuffer", new Object[]{jsPart, header, buffer, offset});
  
      JMFMessage msg = (JMFMessage)jsPart.jmfPart;
      int length = 0;
      int newOffset = offset;
  
      try {
  
        length = msg.getEncodedLength();
  
        // If this is a header (or only) part it also needs a 4 byte length field at the start
        // containing the header length
        if (header) {
          ArrayUtil.writeInt(buffer, offset, length);
          newOffset += ArrayUtil.INT_SIZE;
        }
  
        msg.toByteArray(buffer, newOffset, length);
  
      }
      catch (Exception e) {
        // Dump the message part, and whatever we've managed to encode so far.
        FFDCFilter.processException(e, "com.ibm.ws.sib.mfp.impl.JsMsgObject.encodePartToBuffer", "jmo600", this,
            new Object[] {
              new Object[] { MfpConstants.DM_MESSAGE, msg, theMessage },
              new Object[] { MfpConstants.DM_BUFFER, buffer, Integer.valueOf(offset), Integer.valueOf(length+ArrayUtil.INT_SIZE) }
            }
          );
  
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "encodePartToBuffer encode failed: " + e);
        throw new MessageEncodeFailedException(e);
      }
  
      length += (newOffset - offset);
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "encodePartToBuffer", Integer.valueOf(length));
      return length;
  
    }