From 8f1053d16ae73a88498556b7dfdf7bb0e3967bd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Leroux?= Date: Mon, 2 Jan 2017 14:45:56 +0000 Subject: [PATCH] Minor fix (fix concurrent exception on map remove) --- src/main/java/org/roda/rodain/rules/Rule.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/roda/rodain/rules/Rule.java b/src/main/java/org/roda/rodain/rules/Rule.java index 24147f00..88725110 100644 --- a/src/main/java/org/roda/rodain/rules/Rule.java +++ b/src/main/java/org/roda/rodain/rules/Rule.java @@ -5,6 +5,7 @@ import java.util.Collection; import java.util.Collections; import java.util.HashSet; +import java.util.Iterator; import java.util.Map; import java.util.Observable; import java.util.Observer; @@ -282,11 +283,14 @@ public void update(Observable o, Object arg) { sipNodes.remove(sip.getId()); sips.remove(sip.getId()); setChanged(); - - schemaNodes.forEach(schemaNode -> { - if (schemaNode.isRemoved()) - schemaNodes.remove(schemaNode); - }); + + Iterator iter = schemaNodes.iterator(); + while (iter.hasNext()) { + if(iter.next().isRemoved()){ + iter.remove(); + } + } + if (sips.isEmpty() && schemaNodes.isEmpty()) { notifyObservers("Removed rule"); } else