AbstractMemcacheObjectEncoder.java 文件源码

java
阅读 28 收藏 0 点赞 0 评论 0

项目:couchbase-jvm-core 作者:
@Override
protected void encode(ChannelHandlerContext ctx, Object msg, List<Object> out) throws Exception {
    if (msg instanceof MemcacheMessage) {
        if (expectingMoreContent) {
            throw new IllegalStateException("unexpected message type: " + StringUtil.simpleClassName(msg));
        }

        @SuppressWarnings({ "unchecked", "CastConflictsWithInstanceof" })
        final M m = (M) msg;
        out.add(encodeMessage(ctx, m));
    }

    if (msg instanceof MemcacheContent || msg instanceof ByteBuf || msg instanceof FileRegion) {
        int contentLength = contentLength(msg);
        if (contentLength > 0) {
            out.add(encodeAndRetain(msg));
        } else {
            out.add(Unpooled.EMPTY_BUFFER);
        }

        expectingMoreContent = !(msg instanceof LastMemcacheContent);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号