Clearify when you need to call retain()

This commit is contained in:
Norman Maurer 2013-06-12 23:13:36 +02:00
parent c6886f9d0e
commit 78c6925921
3 changed files with 16 additions and 1 deletions

View File

@ -15,6 +15,7 @@
*/ */
package io.netty.handler.codec; package io.netty.handler.codec;
import io.netty.buffer.ReferenceCounted;
import io.netty.channel.ChannelDuplexHandler; import io.netty.channel.ChannelDuplexHandler;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPromise; import io.netty.channel.ChannelPromise;
@ -45,6 +46,10 @@ import io.netty.util.internal.TypeParameterMatcher;
* } * }
* } * }
* </pre> * </pre>
*
* Be aware that you need to call {@link ReferenceCounted#retain()} on messages that are just passed through if they
* are of type {@link ReferenceCounted}. This is needed as the {@link MessageToMessageCodec} will call
* {@link ReferenceCounted#release()} on encoded / decoded messages.
*/ */
public abstract class MessageToMessageCodec<INBOUND_IN, OUTBOUND_IN> extends ChannelDuplexHandler { public abstract class MessageToMessageCodec<INBOUND_IN, OUTBOUND_IN> extends ChannelDuplexHandler {

View File

@ -16,13 +16,15 @@
package io.netty.handler.codec; package io.netty.handler.codec;
import io.netty.buffer.ByteBufUtil; import io.netty.buffer.ByteBufUtil;
import io.netty.buffer.ReferenceCounted;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.MessageList; import io.netty.channel.MessageList;
import io.netty.util.internal.TypeParameterMatcher; import io.netty.util.internal.TypeParameterMatcher;
/** /**
* {@link ChannelInboundHandlerAdapter} which decodes from one message to an other message * {@link ChannelInboundHandlerAdapter} which decodes from one message to an other message.
*
* *
* For example here is an implementation which decodes a {@link String} to an {@link Integer} which represent * For example here is an implementation which decodes a {@link String} to an {@link Integer} which represent
* the length of the {@link String}. * the length of the {@link String}.
@ -39,6 +41,10 @@ import io.netty.util.internal.TypeParameterMatcher;
* } * }
* </pre> * </pre>
* *
* Be aware that you need to call {@link ReferenceCounted#retain()} on messages that are just passed through if they
* are of type {@link ReferenceCounted}. This is needed as the {@link MessageToMessageDecoder} will call
* {@link ReferenceCounted#release()} on decoded messages.
*
*/ */
public abstract class MessageToMessageDecoder<I> extends ChannelInboundHandlerAdapter { public abstract class MessageToMessageDecoder<I> extends ChannelInboundHandlerAdapter {

View File

@ -16,6 +16,7 @@
package io.netty.handler.codec; package io.netty.handler.codec;
import io.netty.buffer.ByteBufUtil; import io.netty.buffer.ByteBufUtil;
import io.netty.buffer.ReferenceCounted;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOutboundHandlerAdapter; import io.netty.channel.ChannelOutboundHandlerAdapter;
import io.netty.channel.ChannelPromise; import io.netty.channel.ChannelPromise;
@ -39,6 +40,9 @@ import io.netty.util.internal.TypeParameterMatcher;
* } * }
* </pre> * </pre>
* *
* Be aware that you need to call {@link ReferenceCounted#retain()} on messages that are just passed through if they
* are of type {@link ReferenceCounted}. This is needed as the {@link MessageToMessageEncoder} will call
* {@link ReferenceCounted#release()} on encoded messages.
*/ */
public abstract class MessageToMessageEncoder<I> extends ChannelOutboundHandlerAdapter { public abstract class MessageToMessageEncoder<I> extends ChannelOutboundHandlerAdapter {