Skip to content

ConcurrentModificationException on channel manager closing #1725

@kirtanparmar

Description

@kirtanparmar

Describe the bug

Hello

I have developed an Android app with RMQ in which I am utilizing 2 RMQ (RMQ1, RMQ2) with 2 channel for each RMQ (One for publishing and one for consuming).

Currently I am facing an issue related to "java.util.ConcurrentModificationException" which is occurring in "com.rabbitmq.client.impl.ChannelManager.scheduleShutdownProcessing".

Please note that when I face this issue, at that time Android device was in doze mode.

Below I have provided logs for reference. (Replaced actual amqp link with "guest@X.Y.Z.A:1234/Example" and "guest@X.Y.Z.B:1234/Example")

Sep 12, 2025 @ 04:20:23.613 | Connection shutdown on rmq2.example.com : reason= null
Sep 12, 2025 @ 04:20:23.616 | Connection shutdown on rmq1.example.com : reason= null
Sep 12, 2025 @ 04:34:02.077 | rmq1.example.com connection recovery started
Sep 12, 2025 @ 04:34:02.077 | rmq2.example.com connection recovery started
Sep 12, 2025 @ 04:34:02.535 | Connection amqp://guest@X.Y.Z.A:1234/Example has recovered
Sep 12, 2025 @ 04:34:02.537 | Connection amqp://guest@X.Y.Z.B:1234/Example has recovered
Sep 12, 2025 @ 04:34:02.580 | Channel AMQChannel(amqp://guest@X.Y.Z.A:1234/Example,1) has recovered
Sep 12, 2025 @ 04:34:02.585 | Channel AMQChannel(amqp://guest@X.Y.Z.B:1234/Example,1) has recovered
Sep 12, 2025 @ 04:34:02.618 | Channel AMQChannel(amqp://guest@X.Y.Z.B:1234/Example,2) has recovered
Sep 12, 2025 @ 04:34:02.619 | Channel AMQChannel(amqp://guest@X.Y.Z.A:1234/Example,2) has recovered
Sep 12, 2025 @ 04:34:02.619 | Recovering RecordedConsumer[tag=ConsumerAPP, queue=1c336ca0e0480023ca91b508d46772d8db88a68f8549bc41b86122d7144e7e93639bd090b1c35eb02c9c4c5fc49e2b66725fd9249ed17dc3b42579c15dbe995e, autoAck=false, exclusive=false, arguments=null, consumer=example.app.rabbitmq.RabbitMQHelper$consumeBSNHashQueue$1@2efbeef, channel=AMQChannel(amqp://guest@X.Y.Z.B:1234/Example,2)]
Sep 12, 2025 @ 04:34:02.619 | Recovering RecordedConsumer[tag=ConsumerAPP, queue=1c336ca0e0480023ca91b508d46772d8db88a68f8549bc41b86122d7144e7e93639bd090b1c35eb02c9c4c5fc49e2b66725fd9249ed17dc3b42579c15dbe995e, autoAck=false, exclusive=false, arguments=null, consumer=example.app.rabbitmq.RabbitMQHelper$consumeBSNHashQueue$1@7a7b4d0, channel=AMQChannel(amqp://guest@X.Y.Z.A:1234/Example,2)]
Sep 12, 2025 @ 04:34:02.646 | RecordedConsumer[tag=ConsumerAPP, queue=1c336ca0e0480023ca91b508d46772d8db88a68f8549bc41b86122d7144e7e93639bd090b1c35eb02c9c4c5fc49e2b66725fd9249ed17dc3b42579c15dbe995e, autoAck=false, exclusive=false, arguments=null, consumer=example.app.rabbitmq.RabbitMQHelper$consumeBSNHashQueue$1@2efbeef, channel=AMQChannel(amqp://guest@X.Y.Z.B:1234/Example,2)] has recovered
Sep 12, 2025 @ 04:34:02.647 | rmq2.example.com connection recovered
Sep 12, 2025 @ 04:34:02.648 | RecordedConsumer[tag=ConsumerAPP, queue=1c336ca0e0480023ca91b508d46772d8db88a68f8549bc41b86122d7144e7e93639bd090b1c35eb02c9c4c5fc49e2b66725fd9249ed17dc3b42579c15dbe995e, autoAck=false, exclusive=false, arguments=null, consumer=example.app.rabbitmq.RabbitMQHelper$consumeBSNHashQueue$1@7a7b4d0, channel=AMQChannel(amqp://guest@X.Y.Z.A:1234/Example,2)] has recovered
Sep 12, 2025 @ 04:34:02.648 | rmq1.example.com connection recovered
Sep 12, 2025 @ 04:34:02.761 | Uncaught Exception Handler: caught exception -> java.util.ConcurrentModificationException

Here is the stack trace for the exception.

nullat java.util.HashMap$HashIterator.nextNode(HashMap.java:1603)
at java.util.HashMap$KeyIterator.next(HashMap.java:1626)
at java.util.AbstractCollection.addAll(AbstractCollection.java:335)
at java.util.HashSet.(HashSet.java:121)
at com.rabbitmq.client.impl.ChannelManager.scheduleShutdownProcessing(Unknown Source:4)
at com.rabbitmq.client.impl.ChannelManager.handleSignal(Unknown Source:98)
at com.rabbitmq.client.impl.AMQConnection.finishShutdown(Unknown Source:4)
at com.rabbitmq.client.impl.AMQConnection.shutdown(Unknown Source:4)
at com.rabbitmq.client.impl.AMQConnection.handleFailure(Unknown Source:20)
at com.rabbitmq.client.impl.AMQConnection.access$500(Unknown Source:0)
at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(Unknown Source:39)
at java.lang.Thread.run(Thread.java:1119)

Please help.

Reproduction steps

This happens very rarely. So far I have found 2 instances. And if this increases then it will affect application quality.

Expected behavior

I do not know if I am doing anything wrong or not because, recovery happens automatically.

Additional context

Android application and android device was in doze mode.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions