From 600db3fb8a175158b134cfebcff0ff35ffb16b8e Mon Sep 17 00:00:00 2001 From: Dennis Sheirer Date: Wed, 2 Oct 2024 03:23:20 -0400 Subject: [PATCH] #1998 P25 Traffic Channel Manager error ConcurrentModification on Allocated Channels Map, introduced in #1996 --- .../decode/p25/P25TrafficChannelManager.java | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/main/java/io/github/dsheirer/module/decode/p25/P25TrafficChannelManager.java b/src/main/java/io/github/dsheirer/module/decode/p25/P25TrafficChannelManager.java index 3406e71e..6fd999ba 100644 --- a/src/main/java/io/github/dsheirer/module/decode/p25/P25TrafficChannelManager.java +++ b/src/main/java/io/github/dsheirer/module/decode/p25/P25TrafficChannelManager.java @@ -70,7 +70,6 @@ import java.util.Queue; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.LinkedTransferQueue; import java.util.concurrent.locks.ReentrantLock; -import java.util.function.BiConsumer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -171,23 +170,21 @@ public class P25TrafficChannelManager extends TrafficChannelManager implements I try { //Shutdown all existing traffic channels and clear the maps. - mAllocatedTrafficChannelMap.forEach(new BiConsumer() - { - @Override - public void accept(Long aLong, Channel channel) - { - if(!parentChannel.equals(channel)) - { - broadcast(new ChannelEvent(channel, Event.REQUEST_DISABLE)); - } - } - }); - + List trafficChannelsToDisable = new ArrayList<>(mAllocatedTrafficChannelMap.values()); mAllocatedTrafficChannelMap.clear(); + + for(Channel channel : trafficChannelsToDisable) + { + if(!parentChannel.equals(channel)) + { + broadcast(new ChannelEvent(channel, Event.REQUEST_DISABLE)); + } + } + mTS1ChannelGrantEventMap.clear(); mTS2ChannelGrantEventMap.clear(); - //Store the control channel in the allocated channel map so that we don't allocate a traffic channel against it + //Store the current control channel in the allocated channel map so that we don't allocate a traffic channel against it mAllocatedTrafficChannelMap.put(current, parentChannel); } finally