sofastack / sofa-bolt

SOFABolt is a lightweight, easy to use and high performance remoting framework based on Netty.
https://www.sofastack.tech/projects/sofa-bolt/
Apache License 2.0
2.4k stars 856 forks source link

多线程环境下添加EventProcessor报错 #309

Open xzc-coder opened 1 year ago

xzc-coder commented 1 year ago

Describe the bug 当多线程环境下添加EventProcessor时,会报数组越界异常

Expected behavior

当多线程环境下调用com.alipay.remoting.rpc.RpcClient#addConnectionEventProcessor 应该正常添加

Actual behavior

当多线程环境下调用com.alipay.remoting.rpc.RpcClient#addConnectionEventProcessor 报数组越界异常

Steps to reproduce

image

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

com.alipay.remoting.ConnectionEventListener#addConnectionEventProcessor image ArrayList不是线程安全的

Environment

chuailiwu commented 1 year ago

Looks like not considered concurrency,can you fix it?

chuailiwu commented 1 year ago

has fixed by https://github.com/sofastack/sofa-bolt/pull/321

OrezzerO commented 1 year ago

PR https://github.com/sofastack/sofa-bolt/pull/321 's unit test can not reproduce the bug. So i wonder there may be other bugs in this situation.