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

ByteBuffer的array size为0时,会出现iterator的data对象为0 #562

Closed
evazca opened this issue Mar 31, 2021 · 4 comments · Fixed by #563
Closed

ByteBuffer的array size为0时,会出现iterator的data对象为0 #562

evazca opened this issue Mar 31, 2021 · 4 comments · Fixed by #563
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@evazca
Copy link

evazca commented Mar 31, 2021

Describe the bug

发现在特定条件下在statemachine的onApply时iterator.getData()是null。

Expected behavior

不应该出现该情况

Actual behavior

空指针

Steps to reproduce

我们的pb对象只有一个元素为repeated xxx。我们设计的方案为repeated对象可以为空,此时会执行一些特殊逻辑。然后发现pb序列化后生成一个size为0的bytebuffer,可以正常反序列化。该proposal leader可以正常apply,follower报空指针错误。
怀疑问题在rpc处理size为0的bytebuffer这边。

Minimal yet complete reproducer code (or GitHub URL to code)

Environment

  • SOFAJRaft version: 1.3.5
  • JVM version (e.g. java -version): 不重要
  • OS version (e.g. uname -a): 不重要
  • Maven version: 不重要
  • IDE version: 不重要
@killme2008
Copy link
Contributor

简单来讲是不是说你们放了一个空的 ByteBuffer(size=0) 作为 data,在复制到 follower 之后变为 null 了?

@evazca
Copy link
Author

evazca commented Mar 31, 2021

是的

@killme2008
Copy link
Contributor

应该是这行引起的

https://github.com/sofastack/sofa-jraft/blob/master/jraft-core/src/main/java/com/alipay/sofa/jraft/entity/codec/v2/V2Decoder.java#L109

你们先可以暂时兼容处理下,如果为 null 也表示 empty buffer,我们尽快修复下

@killme2008 killme2008 added bug Something isn't working good first issue Good for newcomers labels Mar 31, 2021
@evazca
Copy link
Author

evazca commented Mar 31, 2021

好的,我已经做了null转zero byte的兼容处理了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants