NETTY-406 ProtobufEncoder should also support Message.Builder

* Added support for Message.Builder
This commit is contained in:
Trustin Lee 2011-08-01 03:46:22 +09:00
parent e2655f3c38
commit b9ef785b5b

View File

@ -78,9 +78,12 @@ public class ProtobufEncoder extends OneToOneEncoder {
@Override
protected Object encode(
ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception {
if (!(msg instanceof MessageLite)) {
return msg;
}
if (msg instanceof MessageLite) {
return wrappedBuffer(((MessageLite) msg).toByteArray());
}
if (msg instanceof MessageLite.Builder) {
return wrappedBuffer(((MessageLite.Builder) msg).build().toByteArray());
}
return msg;
}
}