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

[ISSUE #309] Fix addConnectionEventProcessor concurrency problems #312

Closed
wants to merge 1 commit into from

Conversation

zjcscut
Copy link

@zjcscut zjcscut commented Nov 3, 2022

Fix #309

  • Fix addConnectionEventProcessor concurrency problems

@xingdong015
Copy link

Maybe ConnectionEventListener will not be used concurrently,Or under what circumstances would there be concurrency issues?

if (processorList == null) {
this.processors.putIfAbsent(type, new ArrayList<ConnectionEventProcessor>(1));
processorList = this.processors.get(type);
lock.lock();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in #309, it is ArrayList not thread safe. I think it is better to replace ArrayList to a thread safe List implementation such as CopyOnWriteArrayList instead of using a lock.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zjcscut will you adjust it based on the above suggestions?

@chuailiwu
Copy link
Collaborator

it has been fixed

@chuailiwu chuailiwu closed this Apr 17, 2024
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

Successfully merging this pull request may close these issues.

多线程环境下添加EventProcessor报错
5 participants