mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Matthew Swift
19.36.2013 6c857f852f405a08653a4cfd86cc0257e7df486d
opendj-sdk/opends/src/server/org/opends/server/replication/protocol/UpdateMsg.java
@@ -109,6 +109,8 @@
  /**
   * Creates a new UpdateMsg with the given informations.
   * <p>
   * This constructor is only used for testing.
   *
   * @param changeNumber  The ChangeNumber associated with the change
   *                      encoded in this message.
@@ -179,18 +181,6 @@
    return changeNumber.compareTo(msg.getChangeNumber());
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public byte[] getBytes(short reqProtocolVersion)
    throws UnsupportedEncodingException
  {
    // There was no change since version 2.
    return getBytes();
  }
  /**
   * Get the assured mode in this message.
   * @return The assured mode in this message
@@ -355,20 +345,37 @@
  }
  /**
   * Returns the encoded representation of this update message using the current
   * protocol version.
   *
   * @return The encoded representation of this update message.
   * @throws UnsupportedEncodingException
   *           If the message could not be encoded.
   */
  public byte[] getBytes() throws UnsupportedEncodingException
  {
    return getBytes(ProtocolVersion.getCurrentVersion());
  }
  /**
   * This implementation is only called during unit testing, so we are free to
   * force the protocol version. Underlying implementations override this method
   * in order to provide version specific encodings.
   *
   * {@inheritDoc}
   */
  @Override
  public byte[] getBytes() throws UnsupportedEncodingException
  public byte[] getBytes(short protocolVersion)
      throws UnsupportedEncodingException
  {
    /* Encode the header in a byte[] large enough to also contain the payload */
    byte [] resultByteArray =
      encodeHeader(MSG_TYPE_GENERIC_UPDATE, payload.length,
                   ProtocolVersion.getCurrentVersion());
    byte[] resultByteArray = encodeHeader(MSG_TYPE_GENERIC_UPDATE,
        payload.length, ProtocolVersion.getCurrentVersion());
    int pos = resultByteArray.length - payload.length;
    /* Add the payload */
    for (int i=0; i<payload.length; i++,pos++)
    for (int i = 0; i < payload.length; i++, pos++)
    {
      resultByteArray[pos] = payload[i];
    }