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

RequestNettyPBDecoder 类解析半包问题 #12

Open
hligaty opened this issue Jul 18, 2022 · 0 comments
Open

RequestNettyPBDecoder 类解析半包问题 #12

hligaty opened this issue Jul 18, 2022 · 0 comments

Comments

@hligaty
Copy link

hligaty commented Jul 18, 2022

RequestNettyPBDecoder 类的 decode() 在半包读取时出现 opcode 丢失问题。
问题原因是 ByteBuf#readableBytes() 满足 headSize 长度但不满足消息体时,也就是

if (size > readAble - headSize) {
    return;
}

代码段,在下次读取剩余半包时消息体正常读取,但 opcode 和 id 是局部变量而不是方法变量导致为 0,最后抛出 MMException

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