timewalker74 / ffmq

FFMQ - full-java, light-weight, fast JMS 1.1 queuer implementation
GNU Lesser General Public License v3.0
63 stars 16 forks source link

Could not close local connection: ConcurrentModificationException #9

Closed andilem closed 1 year ago

andilem commented 1 year ago

There was a ping timeout detected on a connection, but it could not be closed successfully because of a ConcurrentModificationException:

#97a3338976108b8a ping timeout on client connection, closing socket
#97a3338976108b8a Could not close local connection
java.util.ConcurrentModificationException
    at java.base/java.util.HashMap$HashIterator.nextNode(HashMap.java:1597)
    at java.base/java.util.HashMap$KeyIterator.next(HashMap.java:1620)
    at net.timewalker.ffmq4.common.connection.AbstractConnection.dropTemporaryQueues(AbstractConnection.java:265)
    at net.timewalker.ffmq4.common.connection.AbstractConnection.onConnectionClose(AbstractConnection.java:315)
    at net.timewalker.ffmq4.local.connection.LocalConnection.onConnectionClose(LocalConnection.java:226)
    at net.timewalker.ffmq4.common.connection.AbstractConnection.close(AbstractConnection.java:300)
    at net.timewalker.ffmq4.listeners.ClientProcessor.transportClosed(ClientProcessor.java:348)
    at net.timewalker.ffmq4.transport.tcp.io.TcpPacketTransport.closeTransport(TcpPacketTransport.java:279)
    at net.timewalker.ffmq4.transport.tcp.io.TcpPacketReceiver.run(TcpPacketReceiver.java:89)
    at java.base/java.lang.Thread.run(Thread.java:833)

Would replacing the HashMap by a ConcurrentHashMap cause any other problems?

timewalker74 commented 1 year ago

Thanks for the report,

There is no real thread-safety issues : the error occurs because we are modifying the Set while iterating over it, which is wrong. Fixing it.

timewalker74 commented 1 year ago

Fixed in 4.0.14