List of usage examples for io.netty.buffer ByteBufUtil utf8MaxBytes
public static int utf8MaxBytes(CharSequence seq)
From source file:io.atomix.cluster.messaging.impl.MessageEncoder.java
License:Apache License
private void encodeRequest(InternalRequest request, ByteBuf out) { encodeMessage(request, out);// w ww . j a va2 s. c o m final ByteBuf buf = out.alloc().buffer(ByteBufUtil.utf8MaxBytes(request.subject())); try { final int length = ByteBufUtil.writeUtf8(buf, request.subject()); // write length of message type out.writeShort(length); // write message type bytes out.writeBytes(buf); } finally { buf.release(); } }