Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Revert "Let ProtobufEncoder extend MessageToByteEncoder which makes m…

…ore sense. Related to [#1222]"

This reverts commit 6a9d055.
  • Loading branch information...
commit 2e3b8f13ea902b6c1e56ad36473c400ef1012daa 1 parent d9ac663
Norman Maurer authored
View
14 codec/src/main/java/io/netty/handler/codec/protobuf/ProtobufEncoder.java
@@ -24,7 +24,9 @@
import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import io.netty.handler.codec.LengthFieldPrepender;
-import io.netty.handler.codec.MessageToByteEncoder;
+import io.netty.handler.codec.MessageToMessageEncoder;
+
+import static io.netty.buffer.Unpooled.*;
/**
* Encodes the requested <a href="http://code.google.com/p/protobuf/">Google
@@ -54,16 +56,16 @@
* </pre>
*/
@Sharable
-public class ProtobufEncoder extends MessageToByteEncoder<MessageLiteOrBuilder> {
+public class ProtobufEncoder extends MessageToMessageEncoder<MessageLiteOrBuilder> {
@Override
- protected void encode(ChannelHandlerContext ctx, MessageLiteOrBuilder msg, ByteBuf out) throws Exception {
+ protected Object encode(ChannelHandlerContext ctx, MessageLiteOrBuilder msg) throws Exception {
if (msg instanceof MessageLite) {
- out.writeBytes(((MessageLite) msg).toByteArray());
- return;
+ return wrappedBuffer(((MessageLite) msg).toByteArray());
}
if (msg instanceof MessageLite.Builder) {
- out.writeBytes(((MessageLite.Builder) msg).build().toByteArray());
+ return wrappedBuffer(((MessageLite.Builder) msg).build().toByteArray());
}
+ return null;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.