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

Fatal Exception: java.util.ConcurrentModificationException #710

Open
malik082009 opened this issue May 18, 2022 · 3 comments
Open

Fatal Exception: java.util.ConcurrentModificationException #710

malik082009 opened this issue May 18, 2022 · 3 comments
Labels

Comments

@malik082009
Copy link

malik082009 commented May 18, 2022

I am getting the below mentioned error frequently while I am using in the application and I am using the version
I face this issue in the middle of the app. don't know why.

Fatal Exception: java.util.ConcurrentModificationException at java.util.LinkedHashMap$LinkedHashIterator.nextNode(LinkedHashMap.java:757) at java.util.LinkedHashMap$LinkedKeyIterator.next(LinkedHashMap.java:780) at io.socket.hasbinary.HasBinary._hasBinary(HasBinary.java:47) at io.socket.hasbinary.HasBinary._hasBinary(HasBinary.java:39) at io.socket.hasbinary.HasBinary.hasBinary(HasBinary.java:18) at io.socket.parser.IOParser$Encoder.encode(IOParser.java:27) at io.socket.client.Manager.packet(Manager.java:412) at io.socket.client.Socket.packet(Socket.java:230) at io.socket.client.Socket.access$1000(Socket.java:18) at io.socket.client.Socket$6.run(Socket.java:219) at io.socket.thread.EventThread.exec(EventThread.java:55) at io.socket.client.Socket.emit(Socket.java:198) at io.socket.client.Socket$5.run(Socket.java:183) at io.socket.thread.EventThread$2.run(EventThread.java:80) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:923)

I am using:
implementation('io.socket:socket.io-client:2.0.1') { exclude group: 'org.json', module: 'json' }

Platform:

  • Device: [OnePlus Nord N10]
  • OS: [Android 11]

Same issue reported here

@liangyuanpeng
Copy link

Have some code to reproduce it will be great. or some step to reproduce it.

@seven4pl
Copy link

seven4pl commented Sep 28, 2022

Same here...

For example: sending 300 messages (offline) with AckWithTimeout (5000 ms), and then after eg. 2 seconds emit new message.

Exception java.util.ConcurrentModificationException:
at java.util.LinkedList$ListItr.checkForComodification (LinkedList.java:970)
at java.util.LinkedList$ListItr.next (LinkedList.java:892)
at io.socket.client.Socket$6$1.run (Socket.java:232)
at java.util.TimerThread.mainLoop (Timer.java:563)
at java.util.TimerThread.run (Timer.java:513)

@seven4pl
Copy link

seven4pl commented Oct 4, 2022

@liangyuanpeng temporary solved by adding synchronized - Socket.java:

synchronized(sendBuffer){
          // remove the packet from the buffer (if applicable)
          Iterator<Packet<JSONArray>> iterator = sendBuffer.iterator();
          while (iterator.hasNext()) {
              if (iterator.next().id == ackId) {
                  iterator.remove();
              }
          }
        }

Harsh5488 added a commit to Harsh5488/socket.io-client-java that referenced this issue Jul 8, 2024
Using ConcurrentLinkedQueue for safety
darrachequesne pushed a commit that referenced this issue Jul 10, 2024
Clearing the buffer upon timeout could lead to:

```
java.util.ConcurrentModificationException
	at java.base/java.util.LinkedList$ListItr.checkForComodification(LinkedList.java:970)
	at java.base/java.util.LinkedList$ListItr.next(LinkedList.java:892)
	at io.socket.client.Socket$6$1.run(Socket.java:232)
	at java.base/java.util.TimerThread.mainLoop(Timer.java:556)
	at java.base/java.util.TimerThread.run(Timer.java:506)
```

Related:

- #710
- #727
- #758
- #759
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants