Skip to content

chapter13 nia.chapter13. LogEventDecoder 代码有误 #34

@handosme

Description

@handosme

https://github.com/ReactivePlatform/netty-in-action-cn/blob/ChineseVersion/chapter13/src/main/java/nia/chapter13/LogEventDecoder.java 第31、32行

//提取日志消息
String logMsg = data.slice(idx + 1,
            data.readableBytes()).toString(CharsetUtil.UTF_8);

slice()方法的第二个参数表示分隔的数据长度,而不是截止位置,可以改成

//提取日志消息
int msgLength = data.readableBytes() - idx - 1;
String logMsg = data.slice(idx + 1, msgLength).toString(CharsetUtil.UTF_8);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions