Skip to content
New issue

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

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

Already on GitHub? # to your account

使用guava ConcurrentHashSet解决core.push.BroadcastPushTask的多线程ConcurrentModificationException异常 #31

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

simplexity-ckcclc
Copy link

Broadcast下做流控,异步发送成功future结束后会更新successUserIds的值。同时发送后流控统计数据时会调用successUserIds#toArray()方法。successUserIds的数据结构为HashSet非线程安全,在toArray过程中更新会抛出以下异常。

2018-05-10 09:29:29.749 - [mp-gateway-work-5-2] WARN  - i.n.u.c.AbstractEventExecutor - A task raised an exception. Task: com.mpush.core.push.BroadcastPushTask@79877a99
java.util.ConcurrentModificationException: null
        at java.util.HashMap$HashIterator.nextNode(HashMap.java:1442)
        at java.util.HashMap$KeyIterator.next(HashMap.java:1466)
        at java.util.AbstractCollection.toArray(AbstractCollection.java:196)
        at com.mpush.core.push.BroadcastPushTask.run(BroadcastPushTask.java:87)
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasksFrom(SingleThreadEventExecutor.java:379)
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:354)
        at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:292)
        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)
        at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144)
        at java.lang.Thread.run(Thread.java:748)

… google.ConcurrentHashSet to avoid java.util.ConcurrentModificationException
@justein
Copy link

justein commented Feb 23, 2020

maybe

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants