Netty ObjectDecoder throws java.io.StreamCorruptedException: unexpected end of block data

感情迁移 提交于 2019-12-04 20:11:57

Since the problem occurs while decoding,

You can hex-dump of the received channel buffer to a log before decoding and analyse it later. You have to have your own version of the ObjectDecoder like

    @Override
protected Object decode(
        ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception {

    ChannelBuffer frame = (ChannelBuffer) super.decode(ctx, channel, buffer);
    if (frame == null) {
        return null;
    }


    logger.debug("Hex dump of object frame [" + ChannelBuffers.hexDump(frame) + "]");

    return new CompactObjectInputStream(
            new ChannelBufferInputStream(frame), classResolver).readObject();
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!