diff --git a/codec/src/main/java/io/netty/handler/codec/ReplayingDecoder.java b/codec/src/main/java/io/netty/handler/codec/ReplayingDecoder.java index f1f4025cb5..67ad7311b7 100644 --- a/codec/src/main/java/io/netty/handler/codec/ReplayingDecoder.java +++ b/codec/src/main/java/io/netty/handler/codec/ReplayingDecoder.java @@ -101,12 +101,12 @@ import io.netty.util.internal.StringUtil; *
public class MyDecoder extends {@link ReplayingDecoder}<{@link Integer}, {@link Void}> { + *public class MyDecoder extends {@link ReplayingDecoder}<{@link Void}> { * * private final Queue<Integer> values = new LinkedList<Integer>(); * * {@code @Override} - * public {@link Integer} decode(.., {@link ByteBuf} in) throws Exception { + * public void decode(.., {@link ByteBuf} in, {@link MessageList} out) throws Exception { * * // A message contains 2 integers. * values.offer(buffer.readInt()); @@ -115,18 +115,18 @@ import io.netty.util.internal.StringUtil; * // This assertion will fail intermittently since values.offer() * // can be called more than two times! * assert values.size() == 2; - * return values.poll() + values.poll(); + * out.add(values.poll() + values.poll()); * } * }* The correct implementation looks like the following, and you can also * utilize the 'checkpoint' feature which is explained in detail in the * next section. - *public class MyDecoder extends {@link ReplayingDecoder}<{@link Integer}, {@link Void}> { + *public class MyDecoder extends {@link ReplayingDecoder}<{@link Void}> { * * private final Queue<Integer> values = new LinkedList<Integer>(); * * {@code @Override} - * public {@link Integer} decode(.., {@link ByteBuf} buffer) throws Exception { + * public void decode(.., {@link ByteBuf} buffer, {@link MessageList} out) throws Exception { * * // Revert the state of the variable that might have been changed * // since the last partial decode. @@ -138,7 +138,7 @@ import io.netty.util.internal.StringUtil; * * // Now we know this assertion will never fail. * assert values.size() == 2; - * return values.poll() + values.poll(); + * out.add(values.poll() + values.poll()); * } * }*