Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
handosme opened this issue Jul 3, 2019 · 0 comments
Open

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

handosme opened this issue Jul 3, 2019 · 0 comments

Comments

@handosme
Copy link

handosme commented Jul 3, 2019

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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant