Permalink
Browse files

Revert "Let ProtobufEncoder extend MessageToByteEncoder which makes m…

…ore sense. Related to [#1222]"

This reverts commit 6a9d055.
  • Loading branch information...
1 parent d9ac663 commit 2e3b8f13ea902b6c1e56ad36473c400ef1012daa @normanmaurer normanmaurer committed Apr 2, 2013
Showing with 8 additions and 6 deletions.
  1. +8 −6 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;
}
}

0 comments on commit 2e3b8f1

Please sign in to comment.