@Test void encodePayload_shouldReturnZeroBytesForEmptyMessages() { final Bytes result = encoding.encodePayload(new EmptyMessage()); assertThat(result).isEqualTo(Bytes.EMPTY); }
@Override @SuppressWarnings("unchecked") public <T> Bytes encodePayload(final T message) { if (message instanceof EmptyMessage) { return Bytes.EMPTY; } final RpcPayloadEncoder<T> payloadEncoder = payloadEncoders.getEncoder((Class<T>) message.getClass()); final Bytes payload = payloadEncoder.encode(message); if (payload.isEmpty()) { return payload; } return encodeMessageWithLength(payload); }
LengthPrefixedEncoding implements RpcEncoding { @Override @SuppressWarnings("unchecked") public <T> Bytes encodePayload(final T message) { if (message instanceof EmptyMessage) { return Bytes.EMPTY; } final RpcPayloadEncoder<T> payloadEncoder = payloadEncoders.getEncoder((Class<T>) message.getClass()); final Bytes payload = payloadEncoder.encode(message); if (payload.isEmpty()) { return payload; } return encodeMessageWithLength(payload); } }
LengthPrefixedEncoding implements RpcEncoding { @Override @SuppressWarnings("unchecked") public <T> Bytes encodePayload(final T message) { if (message instanceof EmptyMessage) { return Bytes.EMPTY; } final RpcPayloadEncoder<T> payloadEncoder = payloadEncoders.getEncoder((Class<T>) message.getClass()); final Bytes payload = payloadEncoder.encode(message); if (payload.isEmpty()) { return payload; } return encodeMessageWithLength(payload); } LengthPrefixedEncoding(
      final String name, final RpcPayloadEncoders payloadEncoders, final Compressor compressor); }
LengthPrefixedEncoding implements RpcEncoding { @Override @SuppressWarnings("unchecked") public <T> Bytes encodePayload(final T message) { if (message instanceof EmptyMessage) { return Bytes.EMPTY; } final RpcPayloadEncoder<T> payloadEncoder = payloadEncoders.getEncoder((Class<T>) message.getClass()); final Bytes payload = payloadEncoder.encode(message); if (payload.isEmpty()) { return payload; } return encodeMessageWithLength(payload); } LengthPrefixedEncoding(
      final String name, final RpcPayloadEncoders payloadEncoders, final Compressor compressor); @Override @SuppressWarnings("unchecked") Bytes encodePayload(final T message); @Override RpcByteBufDecoder<T> createDecoder(Class<T> payloadType); @Override String getName(); }
LengthPrefixedEncoding implements RpcEncoding { @Override @SuppressWarnings("unchecked") public <T> Bytes encodePayload(final T message) { if (message instanceof EmptyMessage) { return Bytes.EMPTY; } final RpcPayloadEncoder<T> payloadEncoder = payloadEncoders.getEncoder((Class<T>) message.getClass()); final Bytes payload = payloadEncoder.encode(message); if (payload.isEmpty()) { return payload; } return encodeMessageWithLength(payload); } LengthPrefixedEncoding(
      final String name, final RpcPayloadEncoders payloadEncoders, final Compressor compressor); @Override @SuppressWarnings("unchecked") Bytes encodePayload(final T message); @Override RpcByteBufDecoder<T> createDecoder(Class<T> payloadType); @Override String getName();  }