-
Notifications
You must be signed in to change notification settings - Fork 976
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
Report: ConcurrentModificationException when use AckWithTimout... #759
Comments
I am Working on an Android Project in Kotlin that uses this library for socket. Please provide any fix or update in the library. Here is the stack trace: (io.socket.client.Socket$6$1.run (Socket.java:232)) |
Using ConcurrentLinkedQueue for safety
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
This should be fixed by b00ae8e, included in version Please reopen if needed. |
@darrachequesne hi, I have a very similar case with io.socket.client.Socket.clearAcks, when sending about 50 ACK's with timeout: 4 diffrent devices, Android 13 (SDK 33) and Android 14 (SDK 34), newest socket.io-client-java (version 2.1.1) java.util.ConcurrentModificationException Exception java.util.ConcurrentModificationException:
at java.util.HashMap$HashIterator.nextNode (HashMap.java:1603)
at java.util.HashMap$ValueIterator.next (HashMap.java:1631)
at io.socket.client.Socket.clearAcks (Socket.java:294)
at io.socket.client.Socket.onclose (Socket.java:286)
at io.socket.client.Socket.access$400 (Socket.java:19)
at io.socket.client.Socket$2$4.call (Socket.java:106)
at io.socket.emitter.Emitter.emit (Emitter.java:117)
at io.socket.client.Manager.onclose (Manager.java:472)
at io.socket.client.Manager.access$1100 (Manager.java:22)
at io.socket.client.Manager$4.call (Manager.java:349)
at io.socket.emitter.Emitter.emit (Emitter.java:117)
at io.socket.engineio.client.Socket.onClose (Socket.java:822)
at io.socket.engineio.client.Socket.onError (Socket.java:784)
at io.socket.engineio.client.Socket.access$900 (Socket.java:29)
at io.socket.engineio.client.Socket$4.call (Socket.java:340)
at io.socket.emitter.Emitter.emit (Emitter.java:117)
at io.socket.engineio.client.Transport.onError (Transport.java:66)
at io.socket.engineio.client.transports.WebSocket.access$400 (WebSocket.java:22)
at io.socket.engineio.client.transports.WebSocket$1$5.run (WebSocket.java:107)
at io.socket.thread.EventThread$2.run (EventThread.java:80)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:644)
at java.lang.Thread.run (Thread.java:1012) |
Describe the bug
Report: ConcurrentModificationException when use AckWithTimout...
(no issues with regular Ack(), only with AckWithTimout because of concurrent / thread-safe ...)
To Reproduce
Please fill the following code example:
Client
Platform:
Error
java.util.ConcurrentModificationException
at java.util.LinkedList$ListItr.checkForComodification(LinkedList.java:966)
at java.util.LinkedList$ListItr.next(LinkedList.java:888)
at io.socket.client.Socket$6$1.run(Socket.java:232)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
Fix needed
Need to rewrite Socket.class to support thread-safe????
while (iterator.hasNext()) {
if (iterator.next().id == ackId) { <=== 232
iterator.remove();
}
}
The text was updated successfully, but these errors were encountered: